| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| clear |
|
|
| inputDir='/autofs/cluster/vive/UW_photo_recon/FLAIR_Scan_Data/'; |
| outputDir='/autofs/cluster/vive/UW_photo_recon/FLAIR_Scan_Data/SAMSEG/'; |
| EXVIVO_SAMSEG_FS_DIR='/autofs/space/panamint_005/users/iglesias/fsdevsamsegexvivo/'; |
| ALADIN='/autofs/space/panamint_005/users/iglesias/software/niftyreg-kcl/build/reg-apps/reg_aladin -ln 3 -lp 2 -speeeeed '; |
| nthread=16; |
|
|
| cases={'17-0333', |
| '18-1045', |
| '18-1132', |
| '18-1196', |
| '18-1680', |
| '18-1913', |
| '18-1930', |
| '18-2128', |
| '18-2259'}; |
|
|
| if exist(outputDir,'dir')==0 |
| mkdir(outputDir); |
| end |
|
|
| |
| T=MRIread([EXVIVO_SAMSEG_FS_DIR '/average/samseg/20Subjects_smoothing2_down2_smoothingForAffine2/template.orig.nii']); |
| atlasDir=[EXVIVO_SAMSEG_FS_DIR '/average/samseg/20Subjects_smoothing2_down2_smoothingForAffine2/']; |
| template=[tempdir '/template.nii.gz']; |
| MRIwrite(T,template); |
| T=MRIread(template); |
| for c=1:length(cases) |
| |
| disp(['Preparing grounds for case ' num2str(c) ' of ' num2str(length(cases))]); |
| |
| aux=cases{c}; |
| aux(aux=='-')='_'; |
| inputScan=[inputDir '/NP' aux '.rotated.nii.gz']; |
| |
| odir=[outputDir '/' cases{c} '/']; |
| if exist(odir,'dir')==0 |
| mkdir(odir); |
| end |
| adir=[odir '/atlas/']; |
| if exist(adir,'dir')==0 |
| mkdir(adir); |
| end |
| |
| if exist([adir '/template.mgz'],'file')==0 |
| |
| cmd=[ALADIN ' -ref ' inputScan ' -flo ' template ' -res /tmp/res.nii.gz -aff /tmp/aff.txt' ]; |
| system([cmd ' >/dev/null']); |
| |
| system(['freeview ' inputScan ' /tmp/res.nii.gz']); |
| |
| a=input('Do you like the output? '); |
| |
| if a>0 |
| |
| fid = fopen('/tmp/aff.txt'); |
| M = fscanf(fid,'%f',[4,4])'; |
| fclose(fid); |
| TT=[]; |
| TT.vol=T.vol; |
| TT.vox2ras0=inv(M)*T.vox2ras0; |
| TT.volres=sum(sqrt(TT.vox2ras0(1:3,1:3).^2)); |
| MRIwrite(TT,'/tmp/template.mgz'); |
| |
| else |
| system(['mri_convert ' template ' /tmp/template.mgz >/dev/null']); |
| disp(['Align in freeview and save using only header']); |
| system(['freeview ' inputScan ' /tmp/template.mgz']); |
| end |
| |
| movefile('/tmp/template.mgz',adir); |
| end |
| |
| % copy files to atlas directory |
| copyfile([atlasDir '/atlas_level1.txt.gz' ],adir); |
| copyfile([atlasDir '/atlas_level2.txt.gz' ],adir); |
| copyfile([atlasDir '/compressionLookupTable.txt' ],adir); |
| copyfile([atlasDir '/modifiedFreeSurferColorLUT.txt' ],adir); |
| if exist([adir '/sharedGMMParameters.txt'],'file')==0 |
| a=input('Does the case have cerebellum and brainstem? '); |
| if a > 0 |
| copyfile('./data/sharedGMMParameters.exvivoMRI.txt',[adir '/sharedGMMParameters.txt']); |
| else |
| copyfile('./data/sharedGMMParameters.NoBSorCB.exvivoMRI.txt',[adir '/sharedGMMParameters.txt']); |
| end |
| end |
| |
| % samseg call |
| dd=dir([odir ' |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |