# Correct image and mask using command line

**URL:** <https://discourse.slicer.org/t/correct-image-and-mask-using-command-line/9386>\
**Category:** Radiomics\
**Tags:** dicom, radiomics\
**Created:** [December 4, 2019, 3:07pm UTC](https://discourse.slicer.org/t/correct-image-and-mask-using-command-line/9386 "2019-12-04T15:07:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bassam](https://avatars.discourse-cdn.com/v4/letter/b/b38774/32.png) [@Bassam](https://discourse.slicer.org/u/Bassam)\
**Post date:** [December 4, 2019, 3:07pm UTC](https://discourse.slicer.org/t/correct-image-and-mask-using-command-line/9386/1 "2019-12-04T15:07:23Z")

</div>

Hi pyradiomics team,

kindly I imported DICOM images into 3D slicer and did segmentation and extract the features properly using 3D slicer, then I saved the image and the mask into file. now I wanna make sure that the same features I will get it If i used command line. Unfortunately, I did not get the features by command line using pyradiomics specifying the image and the mask and it showed me an error, here is the message I’ve got it:

C:\features\>pyradiomics pancreas\_image.nrrd pancreas\_label.nrrd  
[2019-12-04 22:13:22] E: radiomics.script: Feature extraction failed!  
Traceback (most recent call last):  
File “C:\Python27\lib\site-packages\pyradiomics-2.2.0.post35+g8da1db7-py2.7-win-amd64.egg\radiomics\scripts\segment.py”, line 70, in \_extractFeatures  
feature\_vector.update(extractor.execute(imageFilepath, maskFilepath, label, label\_channel))  
File “C:\Python27\lib\site-packages\pyradiomics-2.2.0.post35+g8da1db7-py2.7-win-amd64.egg\radiomics\featureextractor.py”, line 273, in execute  
boundingBox, correctedMask = imageoperations.checkMask(image, mask, \*\*\_settings)  
File “C:\Python27\lib\site-packages\pyradiomics-2.2.0.post35+g8da1db7-py2.7-win-amd64.egg\radiomics\imageoperations.py”, line 239, in checkMask  
raise ValueError('Image/Mask datatype or size mismatch. Potential fix: enable correctMask, see ’  
ValueError: Image/Mask datatype or size mismatch. Potential fix: enable correctMask, see Documentation:Usage:Customizing the Extraction:Settings:correctMask for more information  
Case-1\_Image: C:\features\pancreas\_image.nrrd  
Case-1\_Mask: C:\features\pancreas\_label.nrrd

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [December 6, 2019, 3:30pm UTC](https://discourse.slicer.org/t/correct-image-and-mask-using-command-line/9386/2 "2019-12-06T15:30:53Z")

</div>

You probably need to export to labelmap.

See:

> [@The resolutions of segment and mri are different](https://discourse.slicer.org/t/the-resolutions-of-segment-and-mri-are-different/9394):
>
> Operating system: Win 10 Pro x64 Slicer version: 4.10.2 Expected behavior: Actual behavior: Some segmentation file resolutions are different with originial mri image resolutions. ex1) mri - (150, 512, 512) / seg - (44, 101, 101) This seems to happen to the most of the segmentation files with multiple segmentations. I created multiple nodes for each tumor and merged them into one node. Was this the cause for it? Is there any way to fit seg’s res to mri’s? and if the above method causes pr…

> [@Aligning Segmentations and images using python](https://discourse.slicer.org/t/aligning-segmentations-and-images-using-python/7446):
>
> Dear all I have a problem to understand how to use Segmentations nrrd file with image files in Python. My problem is: I’m able to open a stack of images and its segmentations using pynrrd. However I can’t understand how to align the segmentation with the stack of images. Reading the header of the segmentation I can’t understand how to shift the segmentation to align with the original image. The same operation when performed in 3DSlicer is straightforward, and the alignment perfect. So, I …

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 6, 2019, 8:10pm UTC](https://discourse.slicer.org/t/correct-image-and-mask-using-command-line/9386/3 "2019-12-06T20:10:20Z")

</div>

To make things easier, we have made automated segmentation cropping optional. By default, extents of segmentation will match extents of master volume. Cropping can be enabled/disabled in the Save dialog’s additional options section. This feature is available in Slicer Preview Release that you download tomorrow or later.

---

<div class="post-metadata">

**Author:** ![JoostJM](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/joostjm/32/1091_2.png) [@JoostJM](https://discourse.slicer.org/u/JoostJM)\
**Post date:** [December 10, 2019, 6:39am UTC](https://discourse.slicer.org/t/correct-image-and-mask-using-command-line/9386/4 "2019-12-10T06:39:17Z")

</div>

Alternatively, you can enable `correctMask` in the PyRadiomics configuration, which will resample the mask back to the image space.
