raamana / visualqc

VisualQC : assistive tool to ease the quality control workflow of neuroimaging data.
https://raamana.github.io/visualqc/
Apache License 2.0
73 stars 13 forks source link

vqcdeface unable to read files #31

Closed atheyers closed 4 years ago

atheyers commented 4 years ago

Description

So I tried running some test data with vqcdeface using this command

vqcdeface -u C:\Users\atheyers\Documents\defacertest -d defaced.nii.gz -m orig.nii.gz -r defaced

and got this error:

Traceback (most recent call last):
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\defacing.py", line 399, in load_unit
    self.render_img_list.append(imread(rimg_path))
  File "C:\Users\atheyers\AppData\Roaming\Python\Python36\site-packages\matplotl
ib\image.py", line 1410, in imread
    with Image.open(fname) as image:
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\PIL\Image.py", line 2818, in open
    raise IOError("cannot identify image file %r" % (filename if filename else f
p))
OSError: cannot identify image file 'C:\\Users\\atheyers\\Documents\\defacertest
\\test_001\\defaced.nii.gz'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\runpy.py
", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\runpy.py
", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\atheyers\AppData\Local\Programs\Python\Python36-32\Scripts\vqcd
eface.exe\__main__.py", line 9, in <module>
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\__defacing__.py", line 17, in main
    defacing.cli_run()
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\defacing.py", line 650, in cli_run
    wf.run()
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\workflows.py", line 78, in run
    self.loop_through_units()
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\workflows.py", line 182, in loop_through_units
    skip_subject = self.load_unit(unit_id)
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\defacing.py", line 402, in load_unit
    ''.format(rimg_path))
OSError: Unable to read the 3D rendered image @
 C:\Users\atheyers\Documents\defacertest\test_001\defaced.nii.gz

This was working before with a different dataset and I've tried re-running that set and it still works perfectly fine. I tried it on a third dataset and that one failed too. As far as I can tell, there is no difference between the file types that I'm using in the three sets (in fact, the working set is a subset of the third one that failed)

raamana commented 4 years ago

it seems to be confusing the name for rendered image. Try specify the full name for the -r flag like defaced.png with full extension

atheyers commented 4 years ago

Now I'm getting a new error:

Traceback (most recent call last):
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\runpy.py
", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\runpy.py
", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\atheyers\AppData\Local\Programs\Python\Python36-32\Scripts\vqcd
eface.exe\__main__.py", line 9, in <module>
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\__defacing__.py", line 17, in main
    defacing.cli_run()
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\defacing.py", line 650, in cli_run
    wf.run()
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\workflows.py", line 78, in run
    self.loop_through_units()
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\workflows.py", line 188, in loop_through_units
    self.display_unit()
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\defacing.py", line 448, in display_unit
    self.show_mr_images()
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\defacing.py", line 491, in show_mr_images
    self.orig_img]):
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\mrivis\base.py", line 278, in get_slices_multi
    'They must have the shape: {}'.format(self._image_shape))
ValueError: Supplied images are not compatible with this class. They must have t
he shape: [192 256 256]
raamana commented 4 years ago

this means the MRI and defaced images do not both have the same dimensions - did you ensure that?

atheyers commented 4 years ago

Just doublechecked and yes, they both have the same orientation and dimensions.

raamana commented 4 years ago

Run mri_info on both images and show me the result here.. It may be that one has the 4th dim encoded differently for this comparison to fail internally

atheyers commented 4 years ago

Okay, so for the original one it's:

Volume information for orig.nii.gz
          type: nii
    dimensions: 192 x 256 x 256
   voxel sizes: 1.000000, 1.000000, 1.000000
          type: FLOAT (3)
           fov: 192.000
           dof: 0
        xstart: -96.0, xend: 96.0
        ystart: -128.0, yend: 128.0
        zstart: -128.0, zend: 128.0
            TR: 0.00 msec, TE: 0.00 msec, TI: 0.00 msec, flip angle: 0.00 degrees
       nframes: 1
       PhEncDir: UNKNOWN
       FieldStrength: 0.000000
ras xform present
    xform info: x_r =  -1.0000, y_r =  -0.0000, z_r =  -0.0000, c_r =     3.2910
              : x_a =   0.0000, y_a =   1.0000, z_a =  -0.0000, c_a =    28.1280
              : x_s =  -0.0000, y_s =   0.0000, z_s =   1.0000, c_s =   -31.7899
Orientation   : LAS
Primary Slice Direction: axial

voxel to ras transform:
               -1.0000  -0.0000  -0.0000    99.2910
                0.0000   1.0000  -0.0000   -99.8720
               -0.0000   0.0000   1.0000  -159.7899
                0.0000   0.0000   0.0000     1.0000

voxel-to-ras determinant -1

ras to voxel transform:
               -1.0000  -0.0000  -0.0000    99.2910
               -0.0000   1.0000  -0.0000    99.8720
               -0.0000  -0.0000   1.0000   159.7899
               -0.0000  -0.0000  -0.0000     1.0000

and for defaced:

Volume information for defaced.nii.gz
          type: nii
    dimensions: 192 x 256 x 256
   voxel sizes: 1.000000, 1.000000, 1.000000
          type: FLOAT (3)
           fov: 192.000
           dof: 0
        xstart: -96.0, xend: 96.0
        ystart: -128.0, yend: 128.0
        zstart: -128.0, zend: 128.0
            TR: 0.00 msec, TE: 0.00 msec, TI: 0.00 msec, flip angle: 0.00 degrees
       nframes: 1
       PhEncDir: UNKNOWN
       FieldStrength: 0.000000
ras xform present
    xform info: x_r =  -1.0000, y_r =  -0.0000, z_r =  -0.0000, c_r =     3.2910
              : x_a =   0.0000, y_a =   1.0000, z_a =  -0.0000, c_a =    28.1280
              : x_s =  -0.0000, y_s =   0.0000, z_s =   1.0000, c_s =   -31.7899
Orientation   : LAS
Primary Slice Direction: axial

voxel to ras transform:
               -1.0000  -0.0000  -0.0000    99.2910
                0.0000   1.0000  -0.0000   -99.8720
               -0.0000   0.0000   1.0000  -159.7899
                0.0000   0.0000   0.0000     1.0000

voxel-to-ras determinant -1

ras to voxel transform:
               -1.0000  -0.0000  -0.0000    99.2910
               -0.0000   1.0000  -0.0000    99.8720
               -0.0000  -0.0000   1.0000   159.7899
               -0.0000  -0.0000  -0.0000     1.0000
raamana commented 4 years ago

try:

pip uninstall mrivis
pip install -U mrivis

and run the vqcdeface again?

atheyers commented 4 years ago

I tried uninstalling and reinstalling mrivis, but I'm still getting the same errors when running vqcdeface.

raamana commented 4 years ago

show me the latest error, in full detail

atheyers commented 4 years ago

This is the error:

Traceback (most recent call last):
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\runpy.py
", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\runpy.py
", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\atheyers\AppData\Local\Programs\Python\Python36-32\Scripts\vqcd
eface.exe\__main__.py", line 9, in <module>
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\__defacing__.py", line 17, in main
    defacing.cli_run()
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\defacing.py", line 650, in cli_run
    wf.run()
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\workflows.py", line 78, in run
    self.loop_through_units()
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\workflows.py", line 188, in loop_through_units
    self.display_unit()
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\defacing.py", line 448, in display_unit
    self.show_mr_images()
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\visualqc\defacing.py", line 491, in show_mr_images
    self.orig_img]):
  File "c:\users\atheyers\appdata\local\programs\python\python36-32\lib\site-pac
kages\mrivis\base.py", line 280, in get_slices_multi
    ''.format(img.shape, self._image_shape))
ValueError: Supplied images do match in size. This image has dimensions: (181, 2
34, 256) They must all have: [192 256 256]

It's saying there is a dimension mismatch, but both of the actual image files are 192 256 256.

atheyers commented 4 years ago

Okay, so another update. It seems it does work for certain defacers and not for others (I'd only tried one defacer with the original test set, one of the ones that happen to work) But in the headers and images themselves, they all have the same dimensions.

raamana commented 4 years ago

that makes more sense - some defacers are messing the headers, or not maintaining them in sync with actual image data.

which ones were they?

atheyers commented 4 years ago

mridefacer: and pydeface: don't work with the viewer while mri_deface: , afni_refacer and deepdefacer: do work. Quickshear and FreeSurfer skullstrip also don't work, but those make sense since they have different dimensions from the original.

raamana commented 4 years ago

I see - which "viewer" are you referring to? this tool?

atheyers commented 4 years ago

Yeah, I meant vqcdeface

dlevitas commented 3 years ago

I've run into the same issue (ValueError: Supplied images do match in size.), and was wondering if there's been a resolution to this? I'm using version 0.4.8 and the data was defaced using quickshear. Other than re-doing the defacing using a different software package, is there a work around for visualqc_defacing? I double checked to ensure that the original and defaced images have the same dimensions

raamana commented 3 years ago

f55d2533a58117d7b6c07448e6b51d7210858afe fixes this

dlevitas commented 3 years ago

Re-installed and everything seems to work now, thanks!