-
Notifications
You must be signed in to change notification settings - Fork 102
Importing NIfTI data
Aditya P. Apte edited this page Apr 7, 2022
·
6 revisions
The following code snippet shows how to import image from NIfTI format to planC.
% Define location of nii file to import and the the location to save the resulting planC.
niiScanFileName = 'Path\to\niiFile\FileName.nii';
plancSaveName = 'Path\to\save\cerr_planc.mat';
scanName = 'CT';
planC = nii2cerr(niiScanFileName,scanName);
% Save planC
planC = save_planC(planC,[],'passed',plancSaveName);
The following code snippet shows how to import labels mask from NIfTI format to planC.
% Define the location of nii file containing label mask
niiMaskFileName = 'Path\to\niiMaskFile\MaskFileName.nii';
% Define the scan index in planC to associate the labels/structures.
scanNum = 1;
planC = importNiftiSegToPlanC(planC,niiSegFileName,scanNum);
The labels from nii masks are named as ROI_* in planC. The last structure in planC is the union of all the labels in nii file. The following code snippet shows how to change structure names and to delete the combined ROI.
% Define label to name mapping
labelToNameC{1} = 'Lung_left';
labelToNameC{2} = 'Lung_right';
labelToNameC{3} = 'Heart';
labelToNameC{4} = 'Esophagus';
labelToNameC{5} = 'Spinal_cord';
indexS = planC{end};
% Delete the combined ROI, the last structure in planC
numStructs = length(planC{indexS.structures});
planC = deleteStructure(planC,numStructs);
% Rename ROIs
for iStr = 1:length(labelToNameC)
planC{indexS.structures}(iStr).structureName = labelToNameC{iStr};
end