Skip to content

feat: custom output name#1104

Merged
carsen-stringer merged 3 commits intoMouseLand:mainfrom
antoinemeyer5:feat/output-naming
Feb 11, 2025
Merged

feat: custom output name#1104
carsen-stringer merged 3 commits intoMouseLand:mainfrom
antoinemeyer5:feat/output-naming

Conversation

@antoinemeyer5
Copy link

Description

We have got some images in an input A folder and want to use the MouseLand/cellpose models on them. These images have a name that makes them unique and identifiable. After processing the MouseLand/cellpose models, we would like to have the results for each image in a folder B with the same file names as the input files. So image named X in folder B corresponds to image X in folder A after calculation by the AI.

MouseLand/cellpose team already made that possible thanks to the parameters output_name. Unfortunately, it's impossible to set this parameter to an empty string, and that's perfectly normal because we do not want to ever over-write someone's original tif.

Changes made

I have added the check that a different input (dir) and output (savedir) folders are properly passed as parameters and if so, then you don't need to add anything to the output file (output_name) name.

Benefits

In cases where the input folder (dir) and output folder (savedir) are defined and different, you can now keep the exact same name for the results files. This simplifies the steps in a complex workflow, where image analysis steps follow one another and file names are used as identifiers.

Examples

Before:

folder_A / X.tif
folder_B /

New commands:

$ cellpose --pretrained_model nuclei --dir ./folder_A/ --savedir ./folder_B/   # (1)
$ cellpose --pretrained_model nuclei --dir ./folder_A/ --savedir ./folder_B/ --output_name '_res'   # (2)
$ cellpose --pretrained_model nuclei --dir ./folder_A/ --savedir ./folder_B/ --output_name ''   # (3)

# (4)
$ cellpose --pretrained_model nuclei --dir ./folder_A/ --output_name ''

After new different commands:

folder_B / X_cp_masks.tif # (1)
folder_B / X_res.tif # (2)
folder_B / X.tif # (3)

# (4) the user could rewrite the X file, but we prevent this by adding `_cp_masks`
folder_A / X.tif
folder_A / X_cp_masks.tif

@codecov
Copy link

codecov bot commented Feb 11, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 52.69%. Comparing base (95e2f60) to head (4f2229d).
Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
cellpose/__main__.py 50.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1104      +/-   ##
==========================================
+ Coverage   52.68%   52.69%   +0.01%     
==========================================
  Files          18       18              
  Lines        4328     4338      +10     
==========================================
+ Hits         2280     2286       +6     
- Misses       2048     2052       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@carsen-stringer carsen-stringer merged commit 093a409 into MouseLand:main Feb 11, 2025
11 of 12 checks passed
@carsen-stringer
Copy link
Member

thanks, I updated to a samefile check to ensure that the directories are really not the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants