Conversation
Member
|
Thanks Michael, so seg.npy files will still open the same exact way as before? |
mrariden
commented
May 6, 2026
Collaborator
Author
|
use this script to fix intermediate import click
import numpy as np
from pathlib import Path
@click.command()
@click.argument('filename')
def main(filename: str|Path):
filename = Path(filename)
file_data = np.load(filename, allow_pickle=True).item()
color = file_data['current_channel']
if isinstance(color, str):
click.echo(f'found incorrect `color` type: ({str(color)}), changing to int')
file_data['current_channel'] = 0
else:
click.echo('file seems okay, exiting...')
return
new_fn = filename.resolve().with_name(filename.stem[:-4] + '_fixed_seg.npy')
click.echo(f'{">" * 5} Saving fixed file to \t{str(new_fn)}')
np.save(new_fn, file_data)
click.echo('done.')
click.echo('You will have to rename the `_fixed_seg.npy` to end in `_seg.npy` (remove `_fixed_seg.npy`)')
if __name__ == "__main__":
main() |
Collaborator
Author
|
Now the |
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.
Changing the
MainW.colorfrominttostrcaused loading/saving .npy files to fail when loading'current_channel'. Added backwards-compatible check that allows old .npy files to be opened with new cellpose versions. In that case, the behavior is to set default'current_channel'to RGB.Also ensured GUI loads image with
update_plot()when loading .npy file.