Open Fiy-fly opened 1 year ago
Sorry,I already know how to save in NII format, but I'd still like to know how to see the raw segments in the MATLAB workspace
Here are two ways:
Using the GUI, you can "Export Segmentation" and choose "Format: Matlab". This should save the segmentation matrix as a Matlab .mat file, which you can load into the workspace. The segmentation matrix is of datatype uint8, where 0 means no segmented region, and other values mean part of a segmentation, where the values used depend on the type of segmentation. For example, for lung segmentations, 1 is Right and 2 is Left.
You can write a script which uses the API (see Tutorial 3 for an introduction) and fetch the result of the corresponding segmentation plugin using dataset.GetResult()
. The result will usualy be a PTKImage
object, whose property RawImage
is the Matlab matrix containing the segmentation values (same as above). NB be aware the segmentation image you get will be cropped to the lung region of interest by default - if you don't want this and want a full size image, then you would do this by adding an additional "context" argument set to PTKOriginalImage
to the GetResult()
call. For example dataset.GetResult('PTKLeftAndRightLungs', 'PTKOriginalImage');
Here is a rough example script for fetching lung and lobe segmentations using the API (Note I have not tested this!)
PTKAddPaths;
ptk_main = PTKMain();
uid = `PUT_THE_UID_FOR_YOUR_DATASET_HERE`;
dataset = ptk_main.CreateDatasetFromUid(uid);
lung_segmentation = dataset.GetResult('PTKLeftAndRightLungs');
% Now lung_segmentation.RawImage contains the lung segmentation matrix
lobe_segmentation = dataset.GetResult('PTKLobes');
% Now lobe_segmentation.RawImage contains the lobe segmentation matrix
Hello,I don‘t know How to save segmentation results in NIFTI format? I use the “export segmentation ” at GUI ,then I get an RGB image in DICOM format. I was wondering where I should find the original segmentation results in MATLAB.