Skip to content

Importing NIfTI data

aditiiyer edited this page Apr 11, 2019 · 6 revisions

Importing .nii volumes

    % Read .mha file
    fileName = 'Path\to\niiFile\FileName.nii';    
    [vol,info] = nifti_read_volume(fileName);

   % Import .nii scan to planC
   CTOffset = 0;  
   scanName = 'niiScan';
   oldPlanC = []; 
   scanFlag = 0;
   planC = mha2cerr(Ainfo,A,CTOffset,scanName,oldPlanC,scanFlag);

   % Save planC to file
   dirName = 'Path\to\store\cerr\file';
   cerrFileName = 'cerrFile.mat';
   optS = [];
   saveflag = 'passed';
   fName = fullfile(dirName,cerrFileName);
   planC = save_planC(planC,optS,saveflag,fName);

Importing .nii masks

    maskFileName = 'Path\to\niiMaskFile\MaskFileName.nii';    
    mask3M = nifti_read_volume(maskFileName);
    mask3M= flipdim(permute(mask3M,[2,1,3]),3);
    isUniform = 0;
    strName = 'niiMask';
    strCreationScanNum = 1;
    planC = maskToCERRStructure(mask3M,isUniform,strCreationScanNum,strName,planC);
Clone this wiki locally