-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dunamai RuntimeError and UnboundLocalError: local variable 'nZ' referenced before assignment #30
Comments
I've implemented a quick and crude solution for this in my fork to work only for my QSM images: I also solved another problem specific to my data - QSM images in NIfTI pipelines are floating-point values centred around zero, though they can have outliers in either direction. DICOMs for QSM images are usually centred around 2048, so a robust conversion is required, which I've tried to do in my updated run.py. |
I also added a command-line option to enable this. :) If you think this would be useful, I can create a PR or you could let me know if there's a better way? |
@astewartau – thanks for submitting the Issue! I've got a very busy week, but will look into this soon. On the miniconda part – I tend to use pip with my virtual environments, so I haven't tested it extensively with other package managers. This is not a suggestion as a solution, but as a sanity check, have you tried installing nii2cm into a fresh venv via pip following the README instructions? Thanks for the code changes – I'll look at them properly and then get back to you about integration/PR. |
Hi @tomaroberts, thanks for offering to look into this! I don't get the git issue when I use a virtual environment - it seems to only occur in my Miniconda setup. Just a little more information that might be helpful - the susceptibility map uses float data, which I've learned we can store in DICOM if we use the |
I'm not very familiar with I see you've forked the repo. My intention was to have classes for different modalities or subtypes. Your QSM work would align with this. I haven't fleshed it out fully yet, but you can create Classes which inherit the MRI DICOM modules, such as I have done for SVR: https://github.com/tomaroberts/nii2dcm/blob/main/nii2dcm/svr.py You could make an equivalent, let's call it You may also need to edit the command line code so you can supply QSM as a |
Just a quick addition here to link this with #31 - the first issue you describe at the top of your issue, @astewartau, regarding The second part where you highlight the |
@astewartau – I've released v0.1.5 of nii2dcm, which fixes the pip install issue, if you want to try it out. If you are still interested in the integration with your QSM toolbox, let me know and I'll re-read this issue more thoroughly, as it's been a little while. Thanks. |
Thanks so much! That seems to be working well. I may have some time to come back to the scaling issue for floating-point maps such as QSM soon, but for now I've also created a pull request for the undefined variable nZ issue. This issue occurs with valid 3D NIfTI images that store their dimensions slightly differently than assumed (see original post). Hopefully the fix makes sense! :) |
Great! Thanks for PR. Will take a look :) |
Thanks for your work on nii2dcm! I'm considering integrating this as part of my QSM processing toolbox, QSMxT.
However, I'm having problems using it in my miniconda setup:
It is related somehow to the dunamai package. Any idea what could be causing this?
I tried initialising a git repository in the local directory to see if that could be a workaround, but then I have a new problem:
Looking at your code in
nii.py
, I can see that this is happening because of the dimensions of my file:Which will not be handled correctly by the initialization code:
https://github.com/tomaroberts/nii2dcm/blob/09d20e02f61da2aa5e7a2e57bd420828021f0d92/nii2dcm/nii.py#L29C1-L35C58
My file is a 3D volume with 205 slices, each with dimensions 164x205. It is a quantitative susceptibility map with floating-point values in the range of about -4 to +3, with most values around zero.
The text was updated successfully, but these errors were encountered: