Code covered by the BSD License
-
dicom_sort_convert_main(varar...
-
workbar(fractiondone, message...
WORKBAR Graphically monitors progress of calculations
-
centre_header(nii_hdr)
centre nii header files - put the origin at the centre of the image
-
convert_2dto3d_func2(obj, eve...
-
convert_to_analyze_func(data)
get info out of the first DICOM header
-
defmossize(N, tszmos)
-
dump_struct_func(readfile, fp...
-
example_dscm_call
a script-call to dicom_sort_convert_main, for performing convertions
-
execute_sort_and_convert_Call...
whether the conversion is carried out or not depends on the parameter
-
get_dicom_fieldname_func(DICO...
-
get_header_parameters(data)
get the DICOM info out of an example
-
get_readfile_stem_func(DICOM_...
-
isdicomfile(fname)
-
iseven(X)
-
isodd(X)
-
load_nii(filename, img_idx, d...
-
load_nii_hdr(fileprefix)
-
load_nii_img(hdr,filetype,fil...
internal function
-
make_analyze_header(data)
voxel size
-
make_nii(varargin)
Make NIfTI structure specified by an N-D matrix. Usually, N is 3 for
-
make_nii_sr(varargin)
Make nii structure specified by an N-D matrix. Usually, N is 3 for
-
mos2vol(mos, szvol, tszmos)
-
mosind2volind(im, szvol, tszm...
-
mossub2volsub(rm, cm, szvol, ...
-
move_ima_func(data)
-
move_report_func(data)
-
process_one_slice_func(data, ...
do the conversion
-
reco_func(writefile_fid, dim_...
read the k-space data from the .img file
-
reco_raw_data_func(obj,eventd...
-
reformat_data_func(data)
if the 'Advanced' feature are selected in dicom_sort_convert_main, this
-
save_nii(nii, fileprefix, old...
-
save_nii_ext(ext, fid)
Save NIFTI header extension.
-
save_nii_hdr(hdr, fid)
-
search_all_header_func(filena...
search_all_header_function
-
search_text_header_func(filen...
search_text_header_function
-
select_sort_and_convert_Callb...
clear the persistent workbar variables to set the time to zero in case it
-
sortlist_func2(flist, field_n...
-
stringin=strip_banned_charact...
-
tar_ima_func(data)
set a subdirectory, or not
-
tf=isvar(v)
ISVAR True if Variable Exists in Workspace.
-
time_string=secs2hms(time_in_...
SECS2HMS - converts a time in seconds to a string giving the time in hours, minutes and second
-
verify_nii_ext(ext)
Verify NIFTI header extension to make sure that each extension section
-
write_dcm_text_header(dicom_r...
the byte numbers of the starts and ends of the file sections are
-
write_introductory_comments(d...
get info out of the first DICOM header
-
write_scan_details(data)
for multi-echo
-
xform_nii(nii, tolerance, pre...
internal function
-
View all files
from
Siemens DICOM sort and convert to NIfTI
by Simon Robinson
Converts Siemens MRI DICOM data into NIfTI format, and/or anonymises and sorts into scan directories
|
| dump_struct_func(readfile, fp_writefile, anonymise)
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% dump_struct_func(readfile, fp_writefile)
%
% for dumping struct information to a file
% gets information out of the dicom header and
%
% Bugs: Generally fragile and tested for DICOM header structs only
% Only works to two levels of structures (ie. struct.struct)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function dump_struct_func(readfile, fp_writefile, anonymise)
fprintf(fp_writefile, '\n\n*** Parameters extracted using MATLAB''s dicominfo ***\n\n');
[res, dcminfo] = isdicomfile(readfile);
try
names=fieldnames(dcminfo);
catch
disp('');
end
No_fields = length(names);
for n = 1:No_fields
if length (dcminfo.(char(names(n)))) < 200
one_field = dcminfo.(char(names(n)));
field_type = class(one_field);
value_string = '';
switch field_type
case 'logical'
case 'char'
value_string = string_convert(one_field);
case 'int8'
value_string = number_convert(one_field);
case 'uint8'
value_string = number_convert(one_field);
case 'int16'
value_string = number_convert(one_field);
case 'uint16'
value_string = number_convert(one_field);
case 'int32'
value_string = number_convert(one_field);
case 'uint32'
value_string = number_convert(one_field);
case 'int64'
value_string = number_convert(one_field);
case 'uint64'
value_string = number_convert(one_field);
case 'double'
value_string = number_convert(one_field);
case 'single'
value_string = number_convert(one_field);
case 'cell'
case 'struct'
value_string = struct_convert(one_field);
otherwise
end
if strcmp(anonymise, 'yes') == 1
switch char(names(n))
case 'Filename'
end_of_string_marker = strfind(value_string, '.MR.');
value_string = ['ANONYMISED' value_string(end_of_string_marker:end)];
if length(end_of_string_marker) == 0;
value_string = ['ANONYMISED:couldnt_sep_filestring']
end
case 'PatientName'
value_string = 'ANONYMISED';
end
end
full_string = [char(names(n)) ':' value_string];
fprintf(fp_writefile, '%s\n', full_string);
end
end
fprintf(fp_writefile, '\n\n*** End of Parameters extracted using MATLAB''s dicominfo ***\n\n');
end
function value_string = number_convert(one_field)
value_string = ' ';
x_dim_one_field = size(one_field, 1);
if numel(one_field) >=1
try
for i=1:x_dim_one_field
value_string=[value_string num2str(one_field(i)) ' '];
end
catch
disp('');
end
end
end
function value_string = string_convert(one_field)
value_string = ' ';
if numel(one_field) >=1
value_string=[value_string char(one_field(1:end))];
end
end
function value_string = struct_convert(one_field)
names_one_field=fieldnames(one_field);
No_names_one_field = length(names_one_field);
value_string = ' ';
for j=1:No_names_one_field
one_subfield = one_field.(char(names_one_field(j)));
if isnumeric(one_subfield) == 1 && numel(one_subfield) >=1
value_string = [value_string char(one_subfield(1:end))];
elseif ischar(one_subfield) == 1 && numel(one_subfield) >=1
value_string=[value_string char(one_subfield(1:end))];
end
end
end
|
|
Contact us at files@mathworks.com