-
Notifications
You must be signed in to change notification settings - Fork 7
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 bug in BrukerTiffSinglePlaneImagingExtractor
#343
Conversation
Ah, OK, this is a case for a problem when using a single argument to specify plane and channel. Here: roiextractors/src/roiextractors/extractors/tiffimagingextractors/brukertiffimagingextractor.py Lines 226 to 230 in 10aea18
We pass plane_stream (a string identifying the plane) as a stream to I think at least at this level we should seprate them, it would make the implementation easier. |
Thank you @h-mayorquin for looking into this issue. I still think that (following this issue):
would be the way to go, it would follow how @pauladkisson refactored the extractor for ScanImage, I believe we don't have a routing class there either. We didn't know it was a bug because the examples that we've seen for Bruker always followed the convention we built on, I think it would be reasonable to have designated classes instead of a router. |
…streams' into improve_bruker_get_streams
…streams' into improve_bruker_get_streams
Ok, @weiglszonja I found a way of solving this without requiring more changes. I think that the changes we have discussed are more robust and would make the code clear but this should be a intermediate fix. Note that this requires #344 before merging. |
else: # This is the case for when stream_name is a plane_stream | ||
file_names = [file.attrib["filename"] for file in file_elements] | ||
file_names_for_stream = [file for file in file_names if self.stream_name in file] | ||
if file_names_for_stream == []: | ||
raise ValueError( | ||
f"The selected stream '{self.stream_name}' is not in the available channel_streams '{streams['channel_streams']}'!" | ||
) |
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.
Ok, @weiglszonja I found a way of solving this without requiring more changes. I think that the changes we have discussed are more robust and would make the code clear but this should be a intermediate fix. Note that this requires #344 before merging.
Ah I see, this can work. thanks for fixing these issues @h-mayorquin ! I think this is already a great improvement, also with lxml
.
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.
Yes, this is the string ducktyping (changing the workflow depending on the value/shape/content of the string) that I did not want to do but at least it solves the problem. I think it would be better if we had another argument plane_stream or just pass file_paths somewhere as discussed. But I think that discussion is more dififcult and this already solves the bug so...
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.
I agree with you, we can revisit this once we have the bandwidth to do the file_paths
approach.
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.
Feel free to merge #346 into this once finished and let me know when this is ready for final review.
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.
This is ready for final review.
#346 is an optimization on top of this but this PR is the bug fix.
I would prefer to merge this first and then add the optimization as another PR if you are OK with that.
The current code assumes that the channel name (the stream) should be in the filename. This is not the case for some data that I have. Here is a frame element in the correspoding xml
As you can see the current asumption is not valid and therefore the code is a bug. The fix proposed in this PR yses the channelName in the xml element to filter the file paths that correspond to the channel.