Closed gdevenyi closed 4 years ago
Followup here.
Another followup
@bcdarwin is there any interest in this?
Yep, looking into a couple Pyminc issues at the moment, hope to look at this tonight
@gdevenyi -- looking at this again, I now believe this is incorrect. For instance, if I use Display to open a label file created after this change, Display believes the file contains very large values and thus scales the intensity of the labels into oblivion. Similarly mincstats
produces a warning that the maximum value is incorrect.
My understanding is that MINC implements a global scaling (controlled by the volume-wide voxel_range and voxel_valid_range) even if slice scaling is disabled (but I suspect that most label-related tools actually ignore this in favour of the voxel values?). However I'm not sure of the preferable way to deal with potential rounding issues associated with the label volume case. I believe that either this change should be reverted or these two lines should be deleted for the label case.
I did this because it fixed something that was failing for me. I think we need to produce a set of test cases and make sure that voxel_vote and pyminc work properly on them to solve all these corner cases.
I agree that more tests are needed for sure -- I've set up CI for Pyminc recently but it's clearly missing the relevant test, and voxel_vote doesn't have any automated test suite right now. It's been a while, but do you by chance emember what tool wasn't working?
The test code/images in the first post, loading and saving a label file modified the global scaling before, and not after.
i.e. For labels, the real and voxel values should be the same for label files.
After speaking with @jgsled I am convinced (unless I misunderstood the names of the API functions in question) that setting voxel_valid_range to voxel_range is the correct way to eliminate the scaling. Using Pydpiper 0.52, I reproduce the discrepancy between real/voxel values reported by Display above, but note that e.g. the DSURQE atlas itself [admittedly, creating using Pyminc] has the same issue (the Dorr 2008 atlas does not since it has 250 labels and its valid range has been set to 255 which corresponds with the max ushort). Thus, I strongly believe this commit should be reverted, but am unsure if there's any remaining issue.
Hi Ben,
That’s correct. MINC allows for voxel intensity scaling to be either global or per slice, but never absent.
cheers,
John
From: Ben Darwin @.> Reply-To: Mouse-Imaging-Centre/pyminc @.> Date: Thursday, April 28, 2022 at 10:55 AM To: Mouse-Imaging-Centre/pyminc @.> Cc: Subscribed @.> Subject: Re: [Mouse-Imaging-Centre/pyminc] Fix inverted logic in label code (#31)
@gdevenyihttps://github.com/gdevenyi -- looking at this again, I now believe this is incorrect. For instance, if I use Display to open a label file created after this change, Display believes the file contains very large values and thus scales the intensity of the labels into oblivion. Similarly mincstats produces a warning that the maximum value is incorrect.
My understanding is that MINC implements a global scaling (controlled by the volume-wide voxel_range and voxel_valid_range) even if slice scaling is disabled. However I'm not sure of the preferable way to deal with potential rounding issues associated with the label volume case. I believe that either this change should be reverted or these two lines should be deleted for the label case.
— Reply to this email directly, view it on GitHubhttps://github.com/Mouse-Imaging-Centre/pyminc/pull/31#issuecomment-1112309108, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAO7TDE46KOODAAQS6ZKK23VHKRGHANCNFSM4IPHZTQA. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Fixing inverted logic in label code which accidentally allows label files to have scaling applied to them.
Tested with:
Loads in a label file and writes it out.
Before(note voxel value vs real value in bottom left)
After(voxel and real value now correspond)