ExtractChannel and FlatFieldDatasource 5D / multichannel datasource fixes#1654
ExtractChannel and FlatFieldDatasource 5D / multichannel datasource fixes#1654barentine wants to merge 8 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') |
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.
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 ;)
|
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>
|
No apology needed, David! I added a color crop to |
Co-authored-by: Copilot <copilot@github.com>
|
I've added a change to move FlatFieldDataSource to inherit from the 5D XYZTCDataSource. @David-Baddeley let me know if you'd like this PR refactored into a couple smaller ones. |
|
Note that the test failure appears unrelated (and passes on my machine). We probably want to look at whether |
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):