nd2reader icon indicating copy to clipboard operation
nd2reader copied to clipboard

Fix a bug of parsing channel validity

Open hayatoikoma opened this issue 3 years ago • 3 comments

This PR fixes the bug of parsing channel validity and also adds a support of another (probably, newer) metadata format.

The sample nd2 data downloaded from OME in the unit test was not correctly parsed, and the _get_channel_validity_list was returning [True, True, True, True, True, True, True] although the data has only 5 channels. Additionally, the metadata didn't have the unnecessary array format in the metadata, which made it falling back to the except statement much earlier than it should. This bug actually didn't allow us to read an image with more than 7 channels. I assumed that the unnecessary array format was used in older nd2 files, and I kept the original try statement.

I wasn't sure how you are assuring the order of validity is alined with sorted(metadata[six.b('sPlaneNew')].items() in _process_channels_metadata. As you have some comments for this sorting, I left as it is. Would you advise me if I need to touch here?

I didn't add a unit test for this fix because most unit tests seems to be using an artificially generated nd2 data. I can try to add something in test_parser.py if necessary.

Thanks for making this awesome library!

hayatoikoma avatar Nov 13 '21 20:11 hayatoikoma

Code Climate has analyzed commit 02eeda22 and detected 0 issues on this pull request.

View more on Code Climate.

codeclimate[bot] avatar Nov 14 '21 04:11 codeclimate[bot]

@rbnvrw @ggirelli Any chance it can be merged at some point?

hayatoikoma avatar Nov 16 '22 19:11 hayatoikoma

Hej Hayato, thanks for the PR. I'm only a contributor here and I am thus unable to approve or merge PRs. @rbnvrw would be the best for that :)

ggirelli avatar Nov 16 '22 21:11 ggirelli