1 /* ----------------------------- MNI Header -----------------------------------
2 @NAME : parse_dicom_groups.c
3 @DESCRIPTION: Routine to parse dicom file - replicates postconditions
4 of save_transferred_object.c
5 @METHOD :
6 @GLOBALS :
7 @CALLS :
8 @CREATED : June 2001 (Rick Hoge)
9 @MODIFIED :
10 * $Log: parse_dicom_groups.c,v $
11 * Revision 1.1 2003-08-15 19:52:55 leili
12 * Initial revision
13 *
14 * Revision 1.2 2002/03/19 13:13:56 rhoge
15 * initial working mosaic support - I think time is scrambled though.
16 *
17 * Revision 1.1 2001/12/31 17:27:01 rhoge
18 * adding file to repository - works for numa4 non-mos files now
19 *
20 ---------------------------------------------------------------------------- */
21
22 #include <dicomserver.h>
23
24 /* ----------------------------- MNI Header -----------------------------------
25 @NAME : parse_dicom_groups
26 @INPUT : group_list - list of acr-nema groups that make up object
27 @OUTPUT : data_info - information about data object
28 @RETURNS : (nothing)
29 @DESCRIPTION: Routine to parse dicom object
30 @METHOD :
31 @GLOBALS :
32 @CALLS :
33 @CREATED : June 2001 (Rick Hoge)
34 @MODIFIED :
35 ---------------------------------------------------------------------------- */
parse_dicom_groups(Acr_Group group_list,Data_Object_Info * data_info)36 public void parse_dicom_groups(Acr_Group group_list, Data_Object_Info *data_info)
37 {
38 Acr_Group group;
39 Acr_Element element;
40 char patient_name[256];
41
42 unsigned short AcqMat[4];
43 unsigned short freq_rows;
44 unsigned short freq_cols;
45 unsigned short phase_rows;
46 unsigned short phase_cols;
47
48 int maxlen = sizeof(Cstring) - 1;
49
50 // Get info to construct unique identifiers for study, series/acq
51 // for file processing
52 get_identification_info(group_list,
53 &(data_info->study_id), &(data_info->acq_id),
54 &(data_info->rec_num), &(data_info->image_type));
55
56 // Get number of echos, echo number, number of dynamic scans and
57 // dynamic_scan_number
58 data_info->num_echoes =
59 acr_find_int(group_list, SPI_Number_of_echoes, 999);
60 data_info->echo_number =
61 acr_find_int(group_list, ACR_Echo_number, 999);
62 data_info->num_dyn_scans =
63 acr_find_int(group_list, ACR_Acquisitions_in_series, 999);
64 data_info->dyn_scan_number =
65 acr_find_int(group_list, ACR_Acquisition, 999);
66 data_info->global_image_number =
67 acr_find_int(group_list, ACR_Image, 999);
68
69 /* rhoge:
70 new info added to data_info by rhoge: nominal number of slices;
71 this is used in detection of a stream of files with the same
72 acquisition ID number in which there are more files than
73 slices. If the number of signal averages is greater than one,
74 we will assume that this means the acquisition loop was used for
75 dynamic scanning.
76
77 WARNINGS: the same thing may need to be done with `number of
78 partitions' for it to work with 3D scans */
79
80 data_info->num_slices_nominal =
81 acr_find_int(group_list, SPI_Number_of_slices_nominal, 999);
82 data_info->slice_number = 999;
83
84 // identification info needed to generate unique session id
85 // for file names
86 data_info->study_date =
87 acr_find_int(group_list, ACR_Study_date, 999);
88 data_info->study_time =
89 acr_find_int(group_list, ACR_Study_time, 999);
90 data_info->scanner_serialno =
91 acr_find_int(group_list, ACR_Device_serial_number, 999);
92
93 // identification info needed to determine if mosaics used
94
95 element = acr_find_group_element(group_list,ACR_Acquisition_matrix);
96 acr_get_element_short_array(element,4,AcqMat);
97
98 freq_rows = AcqMat[0];
99 freq_cols = AcqMat[1];
100
101 phase_rows = AcqMat[2];
102 phase_cols = AcqMat[3];
103
104 // rows in acq matrix is larger of freq rows and freq columns:
105 data_info->acq_rows = ( freq_rows > freq_cols ? freq_rows : freq_cols );
106 // all images are square, at this time
107 data_info->acq_cols = data_info->acq_rows;
108
109 data_info->rec_rows = acr_find_int(group_list,ACR_Rows, 999);
110 data_info->rec_cols = acr_find_int(group_list,ACR_Columns, 999);
111
112 data_info->num_mosaic_rows=acr_find_int(group_list,EXT_Mosaic_rows, 999);
113 data_info->num_mosaic_cols=acr_find_int(group_list,EXT_Mosaic_columns,999);
114 data_info->num_slices_in_file=
115 acr_find_int(group_list,EXT_Slices_in_file,999);
116
117 // sequence, protocol names (useful for debugging):
118
119 (void) strncpy(data_info->sequence_name,
120 acr_find_string(group_list,ACR_Sequence_name,""),maxlen);
121 (void) strncpy(data_info->protocol_name,
122 acr_find_string(group_list,ACR_Protocol_name,""),maxlen);
123
124 return;
125
126 }
127
128
129