processing_stream_-_image_file_conversion
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
processing_stream_-_image_file_conversion [2010/05/26 17:23] – added the depth argument to findfiles jochen | processing_stream_-_image_file_conversion [2010/05/30 03:36] (current) – added instructions for SPM8 jochen | ||
---|---|---|---|
Line 21: | Line 21: | ||
To ensure that the sorted list of filenames to be imported are in a correct temporal order, the use of the [[renamedicom]] function is highly recommended (unless you can confirm that the files you have already are properly named). | To ensure that the sorted list of filenames to be imported are in a correct temporal order, the use of the [[renamedicom]] function is highly recommended (unless you can confirm that the files you have already are properly named). | ||
- | This functionality is **not yet** available as a compound function, but can be easily achieved by using the following code (adapted to your specific situation, of course): | + | This functionality is **not yet** available as a compound function, but can be easily achieved by using the following code for SPM5 (adapted to your specific situation, of course; wherever necessary and SPM8 instructions require, this is marked!): |
<code matlab>% load the DICOM import job file | <code matlab>% load the DICOM import job file | ||
jobs = neuroelf_file(' | jobs = neuroelf_file(' | ||
+ | % for SPM8 it's ' | ||
jobs = jobs.jobs; | jobs = jobs.jobs; | ||
% use SPM's defaults | % use SPM's defaults | ||
- | spm_defaults; | + | spm_defaults; |
+ | % for SPM8 use spm(' | ||
+ | |||
+ | % ** IF YOU WISH TO USE THE SINGLE-FILE NIFTI FORMAT, SAY | ||
+ | % jobs{1}.util{1}.dicom.convopts.format = ' | ||
+ | % jobs{1}.spm.util.dicom.convopts.format = ' | ||
+ | % ** OTHERWISE THE TWO-FILE HDR+IMG FORMAT IS USED! ** | ||
% change into your study' | % change into your study' | ||
Line 34: | Line 41: | ||
% find all folders that contain DICOM import files (sessions) | % find all folders that contain DICOM import files (sessions) | ||
- | importdirs = findfiles([pwd '/ | + | importdirs = findfiles([pwd '/ |
% remove subjects that have already been imported | % remove subjects that have already been imported | ||
- | donedirs = findfiles([pwd '/ | + | donedirs = findfiles([pwd '/ |
for dc = 1: | for dc = 1: | ||
% take out those which match the CHIP* part | % take out those which match the CHIP* part | ||
- | [study, chip] = fileparts(fileparts(donedirs{dc})); | + | [study, chip] = fileparts(fileparts(fileparts(donedirs{dc}))); |
importdirs(~isemptycell(regexp(importdirs, | importdirs(~isemptycell(regexp(importdirs, | ||
end | end | ||
Line 49: | Line 56: | ||
% find dicom files | % find dicom files | ||
- | dcmfiles = findfiles(importdirs{dc}, | + | dcmfiles = findfiles(importdirs{dc}, |
| | ||
% no files, continue | % no files, continue | ||
Line 58: | Line 65: | ||
% figure out the target folder | % figure out the target folder | ||
[study, target] = fileparts(fileparts(dcmfiles{1})); | [study, target] = fileparts(fileparts(dcmfiles{1})); | ||
+ | | ||
+ | % re-vamp the target folder name (which for us is NUMVOLr_NUMSCAN) | ||
+ | target_particles = regexp(target, | ||
+ | if isempty(target_particles) || ... | ||
+ | numel(target_particles{1}) ~= 2 | ||
+ | continue; | ||
+ | end | ||
+ | target = sprintf(' | ||
+ | str2double(target_particles{1}{2}), | ||
+ | str2double(target_particles{1}{1})); | ||
| | ||
% create target folder | % create target folder | ||
- | target = [fileparts(study) '/run_' target]; | + | target = [fileparts(study) '/func/' target]; |
mkadir(target); | mkadir(target); | ||
| | ||
Line 66: | Line 83: | ||
jobs{1}.util{1}.dicom.data = dcmfiles; | jobs{1}.util{1}.dicom.data = dcmfiles; | ||
jobs{1}.util{1}.dicom.outdir{1} = target; | jobs{1}.util{1}.dicom.outdir{1} = target; | ||
+ | % for SPM8, these two lines must be | ||
+ | % jobs{1}.spm.util.dicom.data = dcmfiles; | ||
+ | % jobs{1}.spm.util.dicom.outdir{1} = target; | ||
| | ||
% run import job | % run import job |
processing_stream_-_image_file_conversion.txt · Last modified: 2010/05/30 03:36 by jochen