ExtractChannel and FlatFieldDatasource 5D / multichannel datasource fixes#1654
Open
barentine wants to merge 7 commits intopython-microscopy:masterfrom
Open
ExtractChannel and FlatFieldDatasource 5D / multichannel datasource fixes#1654barentine wants to merge 7 commits intopython-microscopy:masterfrom
barentine wants to merge 7 commits intopython-microscopy:masterfrom
Conversation
| # chan = image.data_xyztc[:,:,:,:,self.channelToExtract] # fails to preserve channel axis | ||
| chan = image.data_xyztc[:,:,:,:,c:c+1] | ||
|
|
||
| im = ImageStack(chan, titleStub = 'Filtered Image') |
Contributor
There was a problem hiding this comment.
We should really go a step further and try and make this lazy (if practical for the dataset). Otherwise we're going to be forcing lots of stuff into memory un-necessarily.
Member
Author
There was a problem hiding this comment.
I'll have a go at making it lazy, though I don't love letting perfection be the enemy of bug fixing ;)
Contributor
|
Sorry, I didn't mean it had to happen. Before merging ... Was just what I
thought when looking at it.
…On Sat, 25 Apr 2026, 07:51 Andrew E S Barentine, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In PYME/recipes/base.py
<#1654 (comment)>
:
> @@ -1021,7 +1021,11 @@ class ExtractChannel(ModuleBase):
channelToExtract = Int(0)
def _pickChannel(self, image):
- chan = image.data[:,:,:,self.channelToExtract]
+ c = self.channelToExtract
+ # Use data_xyztc (5D, X,Y,Z,T,C) with a slice (c:c+1) rather than an integer index
+ # so the channel axis is preserved, avoiding collapse to a 4D array and re-promotion ambiguity.
+ # chan = image.data_xyztc[:,:,:,:,self.channelToExtract] # fails to preserve channel axis
+ chan = image.data_xyztc[:,:,:,:,c:c+1]
im = ImageStack(chan, titleStub = 'Filtered Image')
I'll have a go at making it lazy, though I don't love letting perfection
be the enemy of bug fixing ;)
—
Reply to this email directly, view it on GitHub
<#1654 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEUSWYALIBC3LX5AISNFOX34XPATNAVCNFSM6AAAAACWXLTDYCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHM2DCNZTGAZDQNJTGA>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AEUSWYHSTZBEQ7N4TK6ISWL4XPATNA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTIMJXGMYDEOBVGMYKM4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/AEUSWYERFUOST7X5P2M2Q734XPATNA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTIMJXGMYDEOBVGMYKM4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you commented.Message ID:
***@***.***
com>
|
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Member
Author
|
No apology needed, David! I added a color crop to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses issues:
ExtractChannel._pickChanneluses legacyimage.dataaccess and collapses the wrong index if you pass it a XYZTC shape [1024, 1024, 1, 1, 4] datasource and try to pick out one of the 4 channelsIs this a bugfix or an enhancement?
bugfix
Proposed changes:
image.data_xyztcaccess inExtractChannelmoduleFlatfieldDataSource currently inherits from
XYTCDataSource, i.e. the old-style datasource base. Certainly it would be better to do a full re-jig, but this was the fastest fix for me.Checklist:
The below is a list of things what will be considered when reviewing PRs. It is not prescriptive, and does not
imply that PRs which touch any of these will be rejected but gives a rough indication of where there is a potential
for hangups (i.e. factors which could turn a 5 min review into a half hour or longer and shunt it to the bottom
of the TODO list).
much simpler if this is kept separate from functional changes. The auto-formatting performed by some editors is particulaly egregious and can lead to files with thousands
of non-functional changes with a few functional changes scattered amoungst them]
If an enhancement (or non-trivial bugfix):