Skip to content

Conversation

@ramroomh
Copy link
Contributor

@ramroomh ramroomh commented Jun 20, 2025

Hi @bendhouseart
Hope all is well

When using e7tools by Siemens, the ReconFilterSize field == 'GAUSSIAN 3 3', for example.

This produces the following error:

ValueError: could not convert string to float: '3 3'

I've added a try/except statement to handle this specific case. I am assuming that any institute running e7tools would run into this problem!

Rami


📚 Documentation preview 📚: https://pet2bids--353.org.readthedocs.build/en/353/

@ramroomh
Copy link
Contributor Author

Hello again, there is second commit, this time related to proper merging of the slices within a single folder. This issue arises from use of e7tools, as it appears that e7tools modifies the DICOM headers for a few bins of the reconstruction and so the output of the dcm2niix4pet is multiple .nii files even though they are the same scan. If you would like to go about this another way instead of forcing dcm2niix to merge, please let me know and happy to contribute in a different way.

Cheers,

Rami

@bendhouseart bendhouseart self-requested a review June 30, 2025 16:10
Copy link
Contributor

@bendhouseart bendhouseart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the PR! Since it seems to fixe your issue and doesn't appear to affect existing users (or at least the CI) this all seems fine to me. Can you bump the version by 0.0.1 in the pyproject.toml file? Or if you're not in a hurry to have these changes pushed to PyPI you could instead change the target branch to development instead of main and have these changes available now.

# people use screwy paths, we do this before running dcm2niix to account for that
image_folder = helper_functions.sanitize_bad_path(self.image_folder)
cmd = f"{self.dcm2niix_path} -b y -w 1 -z y {file_format_args} -o {tempdir_pathlike} {image_folder}"
cmd = f"{self.dcm2niix_path} -b y -m Y -w 1 -z y -s y {file_format_args} -o {tempdir_pathlike} {image_folder}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, sure I think this is fine as it passes on the phantoms and the other CI. I'm still not certain what it is that -s is doing:

-s : single file mode, do not convert other images in folder (y/n, default n)

But again, it's not affecting our CI so I'm pretty okay with it.

@bendhouseart
Copy link
Contributor

bendhouseart commented Jul 1, 2025

@neurolabusc tagging you in as I'm not sure what the -s option is doing as my output with and without it for a folder of mixed dicoms is identical. Can you educate us?

Going to ask @ramroomh if you are able to share the dicoms produced by e7 tools with us, or whether you can generate some with a siemens phantom from this public source https://datacatalog.publicneuro.eu/dataset/PN000001%20OpenNeuroPET%20Phantoms/V1

@neurolabusc
Copy link
Contributor

I suggest fixing the error in these images rather than treating the symptom. I certainly would not merge this change into code designed for robust use with valid DICOM images.

I would caution against using -m y as a default option. This is a desperate option that concatenates images that have substantial differences. For example, images with different XRay exposures will be merged. I would work with the Siemens Research Manager at the location that acquired this to update the e7tools. I would suggest fixing the malformed DICOM images rather than overriding the behavior of dcm2niix. I think the potential for unintended consequences is high.

@ramroomh
Copy link
Contributor Author

ramroomh commented Jul 2, 2025

Thank you @bendhouseart @neurolabusc. I agree what I have is a band-aid soultion and not optimal.

As far as the -s flag, it only forced the merge when -m Y -s Y were both present

Happy to share some reconstructions, thanks to @ltuominen lab for sharing. We have an XNAT instance for sharing and can add you to the relevant project containing the reconstructions. Also, we have a Siemens biograph mMR (PET/MR) and can ask to contribute a phantom from our site (The Royal, Ottawa) if you are interested @bendhouseart?

I think there are two issues though:

  1. Invalid string value for ReconFilterSize. I will see if the string value can be altered in the e7tools paramater settings so that the first commit is not needed
  2. Despite modifying the code to extract the proper ReconFilterSize, there are remaining substantial differences in the DICOM headers. Ill take a deeper look at the 3 separate .nii's generated from the output and identify the differences in the headers, and work with our Siemens Research Manager as needed. It would be helpful to know if you are getting the same output with our reconstructions @bendhouseart

@bendhouseart
Copy link
Contributor

Following the feedback from Chris and Rami I would say that:

Invalid string value for ReconFilterSize. I will see if the string value can be altered in the e7tools paramater settings so that the first commit is not needed

I think this is fine, I'm all for leaving it.

Despite modifying the code to extract the proper ReconFilterSize, there are remaining substantial differences in the DICOM headers. Ill take a deeper look at the 3 separate .nii's generated from the output and identify the differences in the headers, and work with our Siemens Research Manager as needed. It would be helpful to know if you are getting the same output with our reconstructions @bendhouseart

For this specific use case I think a better fix is going to be to allow the input of additional arguments to dcm2niix either via the command line with a --dcm2niix-args flag, an environment variable PET2BIDS_DCM2NIIX_ARGS, or via setting them in the .pet2bidsconfig file globally for your install. That should solve your particular use case and allow other users to get up to all kinds of nonsense (or not).

@ramroomh I'll try to make the changes directly to your branch, but if not I'm just going to implement them in the development branch of pet2bids so that they're available to you.

@ramroomh
Copy link
Contributor Author

ramroomh commented Jul 7, 2025

Allowing additional input sounds like a great fix-- I agree it allows for flexibility. No worries about the branch, thanks for working on this @bendhouseart

bendhouseart added a commit that referenced this pull request Jul 8, 2025
@ramroomh
Copy link
Contributor Author

ramroomh commented Jul 9, 2025

@neurolabusc if you are interested in some raclopride PET reconstructions with JSrecon (Siemens wrapper for e7tools), @ltuominen is happy to share for testing purposes. Let me know and I can add your email to our XNAT project page to download a few cases.

@neurolabusc
Copy link
Contributor

@ramroomh I would be happy to see some examples. Feel free to share demos with my institutional email.

@ramroomh
Copy link
Contributor Author

ramroomh commented Jul 9, 2025

Will do. Will close this as the fixes were addressed in #357.

@ramroomh ramroomh closed this Jul 9, 2025
bendhouseart added a commit that referenced this pull request Jul 10, 2025
Allows for additional option to be set for dcm2niix

Small fix for reconstruction field being cast as float.

* apply changes requested from PR #353
* bump version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants