oncoray / mirp

Medical Image Radiomics Processor
https://oncoray.github.io/mirp/
European Union Public License 1.2
51 stars 14 forks source link

JOSS review item: Functionality / Documentation #92

Closed Matthew-Jennings closed 3 months ago

Matthew-Jennings commented 3 months ago

The Apply Image Filter tutorial is not working for me locally. Specifically when trying to visualise images:

from mirp import extract_images

images = extract_images(
    image=os.path.join(save_dir, "chest_ct", "image"),
    mask=os.path.join(save_dir, "chest_ct", "mask", "DCM_RS_00060.dcm"),
    roi_name="GTV-1",
    image_export_format="native"
)
ValueError                                Traceback (most recent call last)
Cell In[3], [line 3](vscode-notebook-cell:?execution_count=3&line=3)
      [1](vscode-notebook-cell:?execution_count=3&line=1) from mirp import extract_images
----> [3](vscode-notebook-cell:?execution_count=3&line=3) images = extract_images(
      [4](vscode-notebook-cell:?execution_count=3&line=4)     image=os.path.join(save_dir, "chest_ct", "image"),
      [5](vscode-notebook-cell:?execution_count=3&line=5)     mask=os.path.join(save_dir, "chest_ct", "mask", "DCM_RS_00060.dcm"),
      [6](vscode-notebook-cell:?execution_count=3&line=6)     roi_name="GTV-1",
      [7](vscode-notebook-cell:?execution_count=3&line=7)     image_export_format="native"
      [8](vscode-notebook-cell:?execution_count=3&line=8) )

File ~\AppData\Roaming\Python\Python311\site-packages\mirp\extract_features_and_images.py:133, in extract_images(write_images, export_images, write_dir, **kwargs)
     [97](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/matth/Workspace/mirp/docs_source/source/~/AppData/Roaming/Python/Python311/site-packages/mirp/extract_features_and_images.py:97) def extract_images(
     [98](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/matth/Workspace/mirp/docs_source/source/~/AppData/Roaming/Python/Python311/site-packages/mirp/extract_features_and_images.py:98)         write_images: None | bool = True,
     [99](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/matth/Workspace/mirp/docs_source/source/~/AppData/Roaming/Python/Python311/site-packages/mirp/extract_features_and_images.py:99)         export_images: None | bool = False,
    [100](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/matth/Workspace/mirp/docs_source/source/~/AppData/Roaming/Python/Python311/site-packages/mirp/extract_features_and_images.py:100)         write_dir: None | str = None,
    [101](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/matth/Workspace/mirp/docs_source/source/~/AppData/Roaming/Python/Python311/site-packages/mirp/extract_features_and_images.py:101)         **kwargs
    [102](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/matth/Workspace/mirp/docs_source/source/~/AppData/Roaming/Python/Python311/site-packages/mirp/extract_features_and_images.py:102) ):
    [103](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/matth/Workspace/mirp/docs_source/source/~/AppData/Roaming/Python/Python311/site-packages/mirp/extract_features_and_images.py:103)     """
    [104](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/matth/Workspace/mirp/docs_source/source/~/AppData/Roaming/Python/Python311/site-packages/mirp/extract_features_and_images.py:104)     Process images and masks. This function is a wrapper around
    [105](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/matth/Workspace/mirp/docs_source/source/~/AppData/Roaming/Python/Python311/site-packages/mirp/extract_features_and_images.py:105)     :func:`~mirp.extractFeaturesAndImages.extract_features_and_images`.
   (...)
    [131](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/matth/Workspace/mirp/docs_source/source/~/AppData/Roaming/Python/Python311/site-packages/mirp/extract_features_and_images.py:131) 
    [132](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/matth/Workspace/mirp/docs_source/source/~/AppData/Roaming/Python/Python311/site-packages/mirp/extract_features_and_images.py:132)     """
--> [133](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/matth/Workspace/mirp/docs_source/source/~/AppData/Roaming/Python/Python311/site-packages/mirp/extract_features_and_images.py:133)     return extract_features_and_images(
...
--> [368](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/matth/Workspace/mirp/docs_source/source/~/AppData/Roaming/Python/Python311/site-packages/mirp/extract_features_and_images.py:368)     raise ValueError("write_dir argument is required for writing images and masks, but not provided.")
    [369](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/matth/Workspace/mirp/docs_source/source/~/AppData/Roaming/Python/Python311/site-packages/mirp/extract_features_and_images.py:369) if write_features and write_dir is None:
    [370](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/matth/Workspace/mirp/docs_source/source/~/AppData/Roaming/Python/Python311/site-packages/mirp/extract_features_and_images.py:370)     raise ValueError("write_dir argument is required for writing feature tables, but not provided.")

ValueError: write_dir argument is required for writing images and masks, but not provided.

Perhaps a change to the API was made after the tutorial was written? On this point, I highly recommend implementing jupyter notebook tests in your CI. It's a great way to catch this sort of thing. See https://github.com/treebeardtech/nbmake

Matthew-Jennings commented 3 months ago

NB: same issue in the Computing Radiomics Features tutorial

alexzwanenburg commented 3 months ago

Thanks for reporting. I will look into it today. I rebuild both vignettes for 2.2.3. Right now I am not sure where the problem lies.

alexzwanenburg commented 3 months ago

I tested the notebooks using the development branch, and they worked without an issue.

Did you install version 2.2.2 or 2.2.3? Commit 0fe6bc8 changed the default values for extract_images, which made having to provide write_dir redundant for the use-case presented in the tutorials. Running the tutorials with an older version would likely result in the error you reported.

Matthew-Jennings commented 3 months ago

Apologies, you were right, I hadn't upgraded. Both notebooks work now :)