Skip to content

Variance and mask as channel by default - 2#36

Merged
YooSunYoung merged 2 commits intomainfrom
fix-default-2
Jul 14, 2025
Merged

Variance and mask as channel by default - 2#36
YooSunYoung merged 2 commits intomainfrom
fix-default-2

Conversation

@YooSunYoung
Copy link
Member

@YooSunYoung YooSunYoung commented Jun 27, 2025

Fixes #25
Inherits #26

I just cleaned up everything...

@YooSunYoung YooSunYoung marked this pull request as draft June 27, 2025 16:15
@YooSunYoung YooSunYoung marked this pull request as ready for review July 3, 2025 12:17
@YooSunYoung YooSunYoung requested a review from Copilot July 3, 2025 12:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Updates the I/O layer to make multi-channel concatenation the default, remove legacy warnings, and align tests and docs with the new behavior. Key changes include:

  • Change default concat_stdevs_and_mask to True and resolve_channels to True in load/save functions.
  • Remove _warn_about_multi_channel_images and related test contexts.
  • Add _has_variances_or_masks helper, simplify channel validation/resolution logic, and strengthen fallback on read errors.
  • Update test expectations and user-guide examples to reflect new defaults.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/io_test.py Cleaned up warning contexts, adjusted indentation of asserts
src/scitiff/io.py Changed default parameters, removed warning helper, adjusted channel logic, added fallback except clause
docs/user-guide/io.ipynb Updated examples to include new default args and flags
Comments suppressed due to low confidence (2)

src/scitiff/io.py:787

  • The generic type T is used in the function signature but never defined. Introduce a TypeVar declaration, e.g., T = TypeVar('T', sc.DataArray, sc.DataGroup), before using it.
        with values of 'intensities', 'stdevs', and 'mask' (see :class:`~.Channel`).

docs/user-guide/io.ipynb:332

  • [nitpick] Add a space before (default) for readability: change True`(default) to True (default).
    "Or you can simply set the `resolve_channels` argument to be `True`(default) and the loader will try reassembling the data array with mask and variances."

@github-project-automation github-project-automation bot moved this to In progress in Development Board Jul 3, 2025
@YooSunYoung YooSunYoung moved this from In progress to Selected in Development Board Jul 3, 2025
@jokasimr
Copy link

There are a lot of changes to warnings and similar, and I'm not so in the loop on scitiff, so I found it hard to distinguish the changes to the logic. Can you point out the sections of the code where the most important changes are located? Or you can show me in person tomorrow maybe?

Copy link

@jokasimr jokasimr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I got the change now, is it correct to say the main change is that the default value of the concat_stddevs_and_masks changes to True?

What does it mean in this context to concat stddevs and masks?
Do we need to concat stddevs and mask because tiff only supports having one big array containing all "channels" of the image?

@jokasimr jokasimr moved this from Selected to In progress in Development Board Jul 14, 2025
@YooSunYoung
Copy link
Member Author

YooSunYoung commented Jul 14, 2025

@jokasimr

I think I got the change now, is it correct to say the main change is that the default value of the concat_stddevs_and_masks changes to True?

That was fast 😃 ...
Yes, we want to keep the channel handling by default.
So it's not just for concatenating, it's also about splitting them into intensities, stdevs and a mask.

What does it mean in this context to concat stddevs and masks?
Do we need to concat stddevs and mask because tiff only supports having one big array containing all "channels" of the image?

We decided to use channel dimension for stdevs and mask if they are really needed to be stored with the intensities and we don't want to stored them as a plain text.

And tiff only allows same sizes of images across all dimensions so we are concatenating intensities, stdevs and a mask into channel dimension, which is useless for neutron or x-ray images.

I also updated the description of the issue #25 to include more context.

# If there is no intensities channel, it means we cannot resolve channels
# automatically.
# Therefore it returns the DataArray as is.
return da

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this change from being an error to now being ignored? 🤔 If we are asked to resolve_channels but are unable to because we're missing the intensity data or because we don't recognize the channel names, should we not raise then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we decided to resolve the channel by default, you can't tell if it was intentionally set or not.

And as a result of balancing between user experiences and robustness,
we don't want the loader to fail in any cases as much as possible,
and we want to keep the save method as strict as possible.

I thought about setting the default value as None so that we can tell if it's specifically set by user or not.
Do you think we should do that...?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha I see. I think it makes sense to do it like you did, just wanted to double check that it was intentional to remove the errors there.

@YooSunYoung YooSunYoung merged commit f0a5155 into main Jul 14, 2025
4 checks passed
@YooSunYoung YooSunYoung deleted the fix-default-2 branch July 14, 2025 13:59
@github-project-automation github-project-automation bot moved this from In progress to Done in Development Board Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Save/load variances by default

3 participants