raidionics / Raidionics

Software for automatic segmentation and generation of standardized clinical reports of brain tumors from MRI volumes
https://raidionics.github.io/
BSD 2-Clause "Simplified" License
31 stars 4 forks source link

Pre-operative segmentation not detecting manually-set sequence type (T1-CE) #74

Open ft-zhang opened 6 months ago

ft-zhang commented 6 months ago

Describe the bug Uploading my own T1-CE .nii and performing pre-operative segmentation yields an error "No radiological volume for {'timestamp': 0, 'sequence': 'T1-CE', 'labels': None, 'space': {'timestamp': 0, 'sequence': 'T1-CE'}}" even after manually setting the sequence type to T1-CE. This behaviour does not appear with the approved example data.

Computer settings:

To Reproduce

  1. Go to "Import patient"
  2. Click on "Other data type (*.nii)
  3. Open T1-CE .nii
  4. Set sequence type to T1-CE in dropdown
  5. Go to "Actions" and then start pre-operative segmentation

Error messages

Note -- filename anonymized in error output below

DEBUG:root:New patient creation requested. INFO:root:Output patient directory set to: C:\Users\frede.raidionics\patients\temp_patient INFO:root:Renamed current output folder to: C:\Users\frede.raidionics\patients\melody_montano DEBUG:root:Active patient uid changed from None to 84275. DEBUG:root:Loading patient 84275 from memory. INFO:root:New data file imported: 7065_02216760_2019-06-13_ANON_t1_vibe_tra_p2_FS_STRAIGHT DEBUG:root:Unsaved changes - Patient object expanded with new volumes. INFO:root:[MRISeriesLayerWidget] Visibility toggled to True for 7065_02216760_2019-06-13_ANON_t1_vibe_tra_p2_FS_STRAIGHT DEBUG:root:Unsaved changes - MRI volume sequence changed to T1-CE INFO:root:Starting pipeline process for task: preop_segmentation. INFO:root:Starting pipeline process for patient 84275 and task preop_segmentation. INFO:root:Saving patient results in: C:\Users\frede.raidionics\patients\melody_montano DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): github.com:443 DEBUG:urllib3.connectionpool:https://github.com:443 "GET /raidionics/Raidionics-models/releases/download/1.2.0/raidionics_cloud_models_list_github.csv HTTP/1.1" 302 0 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): objects.githubusercontent.com:443 DEBUG:urllib3.connectionpool:https://objects.githubusercontent.com:443 "GET /github-production-release-asset-2e65be/601122702/e623363f-d633-4134-ad39-0a9a03cdbd92?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20240229%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240229T065226Z&X-Amz-Expires=300&X-Amz-Signature=aefbb8d3a2372378dbf32dbc8ca1e6800d641146b8cd16eaea3dfd43cf0dd3b4&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=601122702&response-content-disposition=attachment%3B%20filename%3Draidionics_cloud_models_list_github.csv&response-content-type=application%2Foctet-stream HTTP/1.1" 200 1754 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): github.com:443 DEBUG:urllib3.connectionpool:https://github.com:443 "GET /raidionics/Raidionics-models/releases/download/1.2.0/raidionics_cloud_models_list_github.csv HTTP/1.1" 302 0 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): objects.githubusercontent.com:443 DEBUG:urllib3.connectionpool:https://objects.githubusercontent.com:443 "GET /github-production-release-asset-2e65be/601122702/e623363f-d633-4134-ad39-0a9a03cdbd92?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20240229%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240229T065226Z&X-Amz-Expires=300&X-Amz-Signature=aefbb8d3a2372378dbf32dbc8ca1e6800d641146b8cd16eaea3dfd43cf0dd3b4&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=601122702&response-content-disposition=attachment%3B%20filename%3Draidionics_cloud_models_list_github.csv&response-content-type=application%2Foctet-stream HTTP/1.1" 200 1754 C:\Users\frede\anaconda3\Lib\site-packages\paramiko\transport.py:219: CryptographyDeprecationWarning: Blowfish has been deprecated "class": algorithms.Blowfish, ERROR:root:Pipeline process for patient 84275, for task preop_segmentation failed with: multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "C:\Users\frede\anaconda3\Lib\site-packages\raidionicsrads\Pipelines\SegmentationStep.py", line 71, in setup raise ValueError("No radiological volume for {}.".format(input_json)) ValueError: No radiological volume for {'timestamp': 0, 'sequence': 'T1-CE', 'labels': None, 'space': {'timestamp': 0, 'sequence': 'T1-CE'}}.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\frede\anaconda3\Lib\multiprocessing\pool.py", line 125, in worker result = (True, func(*args, *kwds)) ^^^^^^^^^^^^^^^^^^^ File "C:\Users\frede\anaconda3\Lib\multiprocessing\pool.py", line 48, in mapstar return list(map(args)) ^^^^^^^^^^^^^^^^ File "C:\Research\fgs\segmentation\raidionics\Raidionics-master\utils\backend_logic.py", line 187, in run_pipeline_wrapper run_rads(params[0], params[1]) File "C:\Users\frede\anaconda3\Lib\site-packages\raidionicsrads\compute.py", line 30, in run_rads patient_parameters = pip.execute(patient_parameters=patient_parameters) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\frede\anaconda3\Lib\site-packages\raidionicsrads\Pipelines\PipelineStructure.py", line 90, in execute self._steps[s].setup(patient_parameters) File "C:\Users\frede\anaconda3\Lib\site-packages\raidionicsrads\Pipelines\SegmentationStep.py", line 147, in setup raise ValueError("[SegmentationStep] setup failed.") ValueError: [SegmentationStep] setup failed. """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Research\fgs\segmentation\raidionics\Raidionics-master\utils\backend_logic.py", line 126, in run_pipeline ret = result.get()[0] ^^^^^^^^^^^^ File "C:\Users\frede\anaconda3\Lib\multiprocessing\pool.py", line 774, in get raise self._value File "C:\Users\frede\anaconda3\Lib\multiprocessing\pool.py", line 125, in worker result = (True, func(*args, *kwds)) ^^^^^^^^^^^^^^^^^ File "C:\Users\frede\anaconda3\Lib\multiprocessing\pool.py", line 48, in mapstar return list(map(args)) ^^^^^^^^^^^^^^^^^ File "C:\Research\fgs\segmentation\raidionics\Raidionics-master\utils\backend_logic.py", line 187, in run_pipeline_wrapper run_rads(params[0], params[1]) ^^^^^^^^^^^^^^^^^ File "C:\Users\frede\anaconda3\Lib\site-packages\raidionicsrads\compute.py", line 30, in run_rads patient_parameters = pip.execute(patient_parameters=patient_parameters) ^^^^^^^^^^^^^^^^^ File "C:\Users\frede\anaconda3\Lib\site-packages\raidionicsrads\Pipelines\PipelineStructure.py", line 90, in execute self._steps[s].setup(patient_parameters) ^^^^^^^^^^^^^^^^^ File "C:\Users\frede\anaconda3\Lib\site-packages\raidionicsrads\Pipelines\SegmentationStep.py", line 147, in setup raise ValueError("[SegmentationStep] setup failed.") ^^^^^^^^^^^^^^^^^ ValueError: [SegmentationStep] setup failed.

INFO:root:Saving patient results in: C:\Users\frede.raidionics\patients\melody_montano

Any assistance would be greatly appreciated!

andreped commented 6 months ago

@ft-zhang Not sure what the issue is, but @dbouget should be able to assist you.

I observed that anaconda seems to be used instead of the Python interpreter bundled with Raidionics. That was surprising to me. Have you seen something like this before @dbouget? Windows is kind of strange with its Path variable.

Maybe there is something wrong with our PyInstaller setup? I have previously seen that if two Python versions are on the same build machine, both are bundled with. Maybe not related but PyInstaller Spec file might have a solution for this.


EDIT: It might be that the local Python is used when you spin a new subprocess! That would made a lot of sense as this is outside PyInstaller's control. After Installation, is the Python version inside the raidionics.exe file or outside of it? If outside, I think we have a solution for this :]

ft-zhang commented 6 months ago

Sorry -- forgot to add that I am not using the Windows executable but a conda environment running main.py. Thanks again for your help.

andreped commented 6 months ago

Sorry -- forgot to add that I am not using the Windows executable but a conda environment running main.py. Thanks again for your help.

Which main.py? Are you trying to run Raidionics (the actual GUI software) by downloading the installer, installing it, and running the app? Or do you mean that you are trying to run Raidionics from source, by first installing all dependencies and then running python main.py? Basically what is described here: https://github.com/raidionics/Raidionics/wiki/Developers'-corner#version-10--

If you try to run Raidionics from source, you have to remember that Raidionics only works for a very specific configuration! If you want to do this, you need to use Python 3.8 (and 3.8 only), you have to use the basic Python and not Python from Anaconda. You also have to follow these installation steps as seen here (or at least you should to ensure that everything works fine): https://github.com/raidionics/Raidionics/blob/master/.github/workflows/build_windows.yml#L33

For any other use, please download the installer of Raidionics for Windows from here: https://github.com/raidionics/Raidionics/releases

And then run the program as you would with any other software. No need to run from python directly, unless you have very specific requirements on what you are trying to do. If so, I would likely to know more what you are trying to do, because it might be that Raidionics already supports this :]

ft-zhang commented 6 months ago

Thank you @andreped for your continued attention and support.

I am indeed running from source by installing the Raidionics dependencies manually then running python main.py. I am attempting this as a troubleshooting measure as the issue in my original post above is also occurring with Raidionics installed from the stable Windows installer (i.e. uploading a patient MRI, changing the sequence type to T1-CE, running pre-operative segmentation, and failing silently). The Windows CLI window associated with Raidionics outputs no error messages, hence I am attempting to debug from source.

More broadly -- I would like to be able to programmatically deploy Raidionics segmentation/other tools as part of a pipeline/workflow, and not have to use the GUI. Guidance on this front would also be appreciated.

Thank you again!

dbouget commented 6 months ago

Hi @ft-zhang,

Running Raidionics without GUI

If you are willing to integrate the processing from Raidionics without the need for the GUI, then I recommend you directly look into this repository. The Raidionics RADS library contains the processing backend for running the different segmentation and reporting tasks, while Raidionics itself "simply" bundles the backend with a GUI in addition.

You will find several notebook tutorials to get started which are also available on Colab. Here is the example for running a preoperative segmentation model, on Github and Colab

Debugging the missing radiological volume error

Since you will be running the Python code, you can set break points along the way. I would recommend to set one here, so that you can investigate the content (i.e., MRI volumes and annotations) associated with the current patient to be processed.

If you want to investigate how a folder is parsed to populate a PatientStructure, which could explain why the T1-CE volume is not properly found or associated as T1-CE, you can set a break point here.

Let me know if it helped identifying the issue!

Bayesianworld commented 3 weeks ago

Very similar error, but different situation. I have just set up Raidionincs on a Mac Book Pro (Apple M2 Pro chip, Sonoma 14.5) and am trying to run the test case using the GUI. Downloaded Case27-Flair.nii and Case27-T1.nii, set sequence type to T1-CE and tried to run the pre-operative segmentation(Note: in YouTube tutorial, is says to run glioblastoma model and in Github notes is says meningioma--I have tried both). Fails with following message:

File "raidionicsrads/Pipelines/SegmentationStep.py", line 71, in setup ValueError: No radiological volume for {'timestamp': 0, 'sequence': 'T1-CE', 'labels': None, 'space': {'timestamp': 0, 'sequence': 'T1-CE'}}.

Loading of the files seemed to well and patient was saved in ~/.raidionics/patients/name However, I loaded it from another folder, though that shouldn't be a problem. Any hints? Thanks

dbouget commented 2 weeks ago

Hi @Bayesianworld,

The provided test-case images are compatible with either the glioblastoma or meningioma model. The meningioma model is simply "faster" to run because it does not require the segmentation of the brain to happen beforehand.

You could try letting Raidionics identify itself the MR sequence for each provided input by leaving the following box unticked: Settings > Preferences > Inputs / Outputs > Use manual MRI sequences. With the two provided images, the automatic classification method works properly. image

You can load the two images from wherever on your machine, it should not pose any problem indeed. What I would recommend is to try running the following:

Bayesianworld commented 2 weeks ago

Thanks for the quick reply, but still no luck. Here is most of the log file: 16/08/2024 13.43 ; urllib3.connectionpool ; DEBUG ; Starting new HTTPS connection (1): github.com:443 16/08/2024 13.43 ; urllib3.connectionpool ; DEBUG ; https://github.com:443 "GET /raidionics/Raidionics-models/releases/download/1.2.0/raidionics_cloud_models_list_github.csv HTTP/1.1" 302 0 16/08/2024 13.43 ; urllib3.connectionpool ; DEBUG ; Starting new HTTPS connection (1): objects.githubusercontent.com:443 16/08/2024 13.43 ; urllib3.connectionpool ; DEBUG ; https://objects.githubusercontent.com:443 "GET /github-production-release-asset-2e65be/601122702/fe5a25c0-67a9-4910-a41c-ab75830fb390?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20240816%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240816T204400Z&X-Amz-Expires=300&X-Amz-Signature=6a022b10c91d04bd293e657e21790582e7186c39cfbf8e1bea91e3033b4ab2ea&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=601122702&response-content-disposition=attachment%3B%20filename%3Draidionics_cloud_models_list_github.csv&response-content-type=application%2Foctet-stream HTTP/1.1" 200 2660 16/08/2024 13.43 ; urllib3.connectionpool ; DEBUG ; Starting new HTTPS connection (1): github.com:443 16/08/2024 13.43 ; urllib3.connectionpool ; DEBUG ; https://github.com:443 "GET /raidionics/Raidionics-models/releases/download/1.2.0/raidionics_cloud_models_list_github.csv HTTP/1.1" 302 0 16/08/2024 13.43 ; urllib3.connectionpool ; DEBUG ; Starting new HTTPS connection (1): objects.githubusercontent.com:443 16/08/2024 13.43 ; urllib3.connectionpool ; DEBUG ; https://objects.githubusercontent.com:443 "GET /github-production-release-asset-2e65be/601122702/fe5a25c0-67a9-4910-a41c-ab75830fb390?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20240816%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240816T204400Z&X-Amz-Expires=300&X-Amz-Signature=6a022b10c91d04bd293e657e21790582e7186c39cfbf8e1bea91e3033b4ab2ea&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=601122702&response-content-disposition=attachment%3B%20filename%3Draidionics_cloud_models_list_github.csv&response-content-type=application%2Foctet-stream HTTP/1.1" 200 2660 16/08/2024 13.43 ; root ; ERROR ; Pipeline process for patient 81949, for task preop_segmentation failed with: multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "raidionicsrads/Pipelines/SegmentationStep.py", line 71, in setup ValueError: No radiological volume for {'timestamp': 0, 'sequence': 'T1-CE', 'labels': None, 'space': {'timestamp': 0, 'sequence': 'T1-CE'}}. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "multiprocessing/pool.py", line 125, in worker File "multiprocessing/pool.py", line 48, in mapstar File "utils/backend_logic.py", line 187, in run_pipeline_wrapper run_rads(params[0], params[1]) File "raidionicsrads/compute.py", line 30, in run_rads File "raidionicsrads/Pipelines/PipelineStructure.py", line 90, in execute File "raidionicsrads/Pipelines/SegmentationStep.py", line 147, in setup ValueError: [SegmentationStep] setup failed. """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "utils/backend_logic.py", line 126, in run_pipeline ret = result.get()[0] File "multiprocessing/pool.py", line 771, in get ValueError: [SegmentationStep] setup failed. 16/08/2024 13.43 ; root ; INFO ; Saving patient results in: /Users/markphillips/.raidionics/patients/micheal_vallery

Bayesianworld commented 17 hours ago

Your advice to unblock "Use manual MRI sequences" worked. The test case then proceeded as advertised. Thanks