Closed DanXieJY closed 10 months ago
It looks like this needs to be updated to use the new syntax - is that what you tried?
https://github.com/AIM-Harvard/pyradiomics/blob/master/radiomics/scripts/__init__.py#L353
It looks like this needs to be updated to use the new syntax - is that what you tried?
https://github.com/AIM-Harvard/pyradiomics/blob/master/radiomics/scripts/__init__.py#L353
Yes, I've tried that but the new error prompted:
[2023-12-05 00:21:16] E: radiomics.script: Error extracting features! Traceback (most recent call last): File "/root/Slicer-5.6.0-linux-amd64/slicer.org/Extensions-32390/SlicerRadiomics/lib/python3.9/site-packages/radiomics/scripts/init.py", line 135, in run results = self._processCases(caseGenerator) File "/root/Slicer-5.6.0-linux-amd64/slicer.org/Extensions-32390/SlicerRadiomics/lib/python3.9/site-packages/radiomics/scripts/init.py", line 233, in _processCases setting_overrides = self._parseOverrides() File "/root/Slicer-5.6.0-linux-amd64/slicer.org/Extensions-32390/SlicerRadiomics/lib/python3.9/site-packages/radiomics/scripts/init.py", line 353, in _parseOverrides yaml = YAML(typ='safe', pure=True) NameError: name 'YAML' is not defined
It looks like with this tool you need to explicitly import the YAML object:
https://yaml.readthedocs.io/en/latest/basicuse/#basic-usage
If you get it working could you post a pull request?
It looks like with this tool you need to explicitly import the YAML object:
https://yaml.readthedocs.io/en/latest/basicuse/#basic-usage
If you get it working could you post a pull request?
Thank you for the quick response. I tried adding "from ruamel.yaml import YAML" to the top of the init.py file, but another error came. Sorry I'm very new to this area and hope for further guidance.
RadiomicsCLI standard error:
[2023-12-05 11:12:38] I: radiomics.script: Starting PyRadiomics (version: 3.1.0a2.post8+g6a761c4) [2023-12-05 11:12:38] I: radiomics.script: Processing input... [2023-12-05 11:12:38] E: radiomics.script: Error extracting features! Traceback (most recent call last): File "/root/Slicer-5.6.0-linux-amd64/slicer.org/Extensions-32390/SlicerRadiomics/lib/python3.9/site-packages/radiomics/scripts/init.py", line 136, in run results = self._processCases(caseGenerator) File "/root/Slicer-5.6.0-linux-amd64/slicer.org/Extensions-32390/SlicerRadiomics/lib/python3.9/site-packages/radiomics/scripts/init.py", line 234, in _processCases setting_overrides = self._parseOverrides() File "/root/Slicer-5.6.0-linux-amd64/slicer.org/Extensions-32390/SlicerRadiomics/lib/python3.9/site-packages/radiomics/scripts/init.py", line 355, in _parseOverrides yaml.load(...) File "/root/Slicer-5.6.0-linux-amd64/slicer.org/Extensions-32390/SlicerRadiomics/lib/python3.9/site-packages/ruamel/yaml/main.py", line 449, in load constructor, parser = self.get_constructor_parser(stream) File "/root/Slicer-5.6.0-linux-amd64/slicer.org/Extensions-32390/SlicerRadiomics/lib/python3.9/site-packages/ruamel/yaml/main.py", line 500, in get_constructor_parser self.reader.stream = stream File "/root/Slicer-5.6.0-linux-amd64/slicer.org/Extensions-32390/SlicerRadiomics/lib/python3.9/site-packages/ruamel/yaml/reader.py", line 113, in stream raise YAMLStreamError('stream argument needs to have a read() method') ruamel.yaml.error.YAMLStreamError: stream argument needs to have a read() method
I'm not too familiar with this package either, but based on the message I think you need to pass it an open file not the name of the file. So something like:
schemaFile, schemaFuncs = radiomics.getParameterValidationFiles()
with open(schemaFile) as schema:
settingsSchema = yaml.safe(schema)['mapping']['setting']['mapping']
If you can't find a combination that works, next time post your changed code along with the error message to make debugging clearer.
I'm not too familiar with this package either, but based on the message I think you need to pass it an open file not the name of the file. So something like:
schemaFile, schemaFuncs = radiomics.getParameterValidationFiles() with open(schemaFile) as schema: settingsSchema = yaml.safe(schema)['mapping']['setting']['mapping']
If you can't find a combination that works, next time post your changed code along with the error message to make debugging clearer.
I finally made it run successfully!! Thank you for the precious advice. Below is what I changed to https://github.com/AIM-Harvard/pyradiomics/blob/master/radiomics/scripts/__init__.py
from ruamel.yaml import YAML
yaml = YAML(typ='safe', pure=True)
settingsSchema = yaml.load(schema)['mapping']['setting']['mapping']
Thanks for reporting back with the solution π
Would you be able to make a pull request to update the repository with these changes?
Thanks for reporting back with the solution π
Would you be able to make a pull request to update the repository with these changes?
For sure! I am now trying to pull a request. Thanks again for the help!
Hi there. Recently I've been trying to use the SlicerRadiomics to extract radiomics features and I also got this problem. I only got table title in the result table. I'm using a Slicer 5.7.0 and a SlicerRadiomics version c29d8a7 (2024-01-01) on Windows 11. So how can I fix this problem or bypass the problem? Thank you for your attention!
I tried yesterday with the windows stable and got a more recent radiomics code that worked.
I wasn't able to get a more recent build for the current stable 5.6.1 though, so maybe there's a configuration issue or something wrong with the extension update mechanism. @jcfr or @lassoan have you seen extension update issues?
Most likely the problem is that the SlicerRadiomics superbuild specifies pyradiomics version using the branch name origin/master
instead of a hash. The package manager is smart enough that it will not download and build a package again if it has that package already.
The fix is to change origin/master
to the latest hash (146e3bd0971336913f9c9f49ce535bc4663ca5c2
) in External_python-pyradiomics.cmake
.
Thanks Andras, let's give that a try. π
https://github.com/AIM-Harvard/SlicerRadiomics/commit/30e27987d918f2b0b6a65dba2f910fbe681e8f69
Thank you all for your remarkable work. I've downloaded the Slicer 5.0.2 and used the compatible SlicerRadiomics, and it worked well on my computer. I guess I should stick to the older version for now. Thanks again!
The fix works well! You can update SlicerRadiomics extension in the Extensions Manager in Slicer-6.1.
Hi, I've been trying to use the newly updated SlicerRadiomics package to extract radiomics features, but the error below prompted every time I clicked apply. There were only table titles in the tables. At first I thought it was due to the setting of my machine. But after I tried 3 different machines, including win and linux, the same thing happened. I've tried Slicer 5.3-5.6, and even manually changed the py files but nothing worked. Hope someone could help me fix this problem. Thanks!!
[2023-12-04 00:42:47] I: radiomics.script: Processing input... [2023-12-04 00:42:47] E: radiomics.script: Error extracting features! Traceback (most recent call last): File "/home/ubuntu/Slicer-5.6.0-linux-amd64/slicer.org/Extensions-32390/SlicerRadiomics/lib/python3.9/site-packages/radiomics/scripts/init.py", line 135, in run results = self._processCases(caseGenerator) File "/home/ubuntu/Slicer-5.6.0-linux-amd64/slicer.org/Extensions-32390/SlicerRadiomics/lib/python3.9/site-packages/radiomics/scripts/init.py", line 233, in _processCases setting_overrides = self._parseOverrides() File "/home/ubuntu/Slicer-5.6.0-linux-amd64/slicer.org/Extensions-32390/SlicerRadiomics/lib/python3.9/site-packages/radiomics/scripts/init.py", line 353, in _parseOverrides settingsSchema = yaml.safe_load(schema)['mapping']['setting']['mapping'] File "/home/ubuntu/Slicer-5.6.0-linux-amd64/slicer.org/Extensions-32390/SlicerRadiomics/lib/python3.9/site-packages/ruamel/yaml/main.py", line 1105, in safe_load error_deprecation('safe_load', 'load', arg="typ='safe', pure=True") File "/home/ubuntu/Slicer-5.6.0-linux-amd64/slicer.org/Extensions-32390/SlicerRadiomics/lib/python3.9/site-packages/ruamel/yaml/main.py", line 1037, in error_deprecation raise AttributeError(s) AttributeError: "safe_load()" has been removed, use
yaml = YAML(typ='safe', pure=True) yaml.load(...)
instead of file "/home/ubuntu/Slicer-5.6.0-linux-amd64/slicer.org/Extensions-32390/SlicerRadiomics/lib/python3.9/site-packages/radiomics/scripts/init.py", line 353
settingsSchema = yaml.safe_load(schema)['mapping']['setting']['mapping']