-
Notifications
You must be signed in to change notification settings - Fork 260
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
FIX: Accommodate Python 3 in DICOM slice sorting #728
Conversation
Thanks for this. Can you provide a minimal reproduction of the issue you ran into? Given that, it might be easier to write a test. |
I can't provide the DICOMs I was using, but any should do: import glob
from nibabel.nicom import dicomreaders
fnames = glob.glob("*.dcm")
wrappers = [dicomreaders.wrapper_from_file(f) for f in fnames]
series = dicomreaders.slices_to_series(wrappers) Output before commit:
|
Cool. There are some |
Codecov Report
@@ Coverage Diff @@
## master #728 +/- ##
==========================================
+ Coverage 89.39% 89.56% +0.17%
==========================================
Files 93 93
Lines 11476 11511 +35
Branches 1992 2002 +10
==========================================
+ Hits 10259 10310 +51
+ Misses 881 861 -20
- Partials 336 340 +4
Continue to review full report at Codecov.
|
Apologies for the gross derivation of the test data path, all the other tests in that suite use data in Not sure why coverage didn't change; I can't find any other tests that call |
So it looks like there are actually separate DICOMs in As to the coverage, it did update, but because AppVeyor is failing, CodeCov isn't updating the comment. The AppVeyor failure looks unrelated, so don't worry about that. |
It was my understanding that this function is meant to take single-slice dicoms from one or more series, separate them into series, and then sort the slices (apparently only along the z-dimension). The two test files I used in Additionally, one of the two dicoms in Let me know your thoughts on how/whether to proceed. Perhaps we can copy the two files I used into the nicom test data directory, use all the .dcm files (except maybe the multiframe one), and add a test to make sure it separates the series? |
TEST: Move test DICOMs into nicom/tests/data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This looks good. I don't suppose there's any chance of digging up a file that hits the _third_pass
condition?
nibabel/nibabel/nicom/dicomreaders.py
Lines 151 to 154 in 28c4576
if len(set(zs)) < len(zs): # not unique zs | |
# third pass | |
out_vol_lists += _third_pass(vol_list) | |
continue |
TEST: Restore dicom files used for DFT
We could duplicate one of the slices, and append it to the list of wrappers. That should register as a duplicated z-value, and call I might be able to tackle that some time this weekend, if you think it's the right move. |
On the whole more coverage is better, but it should be a valid DICOM. I'll confess to knowing little about the format, so I don't know if what you describe is normal or something that will technically work but isn't actually valid. Another thing to consider is looking through PyDICOM's test data directory for something that triggers this code. |
I'm going to go ahead and merge. If you get a chance to add a new test file, it would be highly appreciated. |
Looks like
list.sort()
in Python 3 requires akey
instead ofcmp
parameter, which has to be given as a keyword argument.The function that uses them (
nicom.dicomreaders.slices_to_series()
) doesn't have a test, and I wasn't sure whether there was any appropriate test data to use in one, so I didn't write one. I'd be happy to if someone has thoughts on what data to use.