Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 8, 2025

Implements a new Snakemake rule that creates Imaris datasets from SPIM data based on atlas region bounding boxes, using zarrnii's get_region_bounding_box(), crop(), and to_imaris() functions. The level wildcard defaults to 0 for high-resolution output.

Implementation

  • New rule: create_imaris_crops in patches.smk following the pattern of create_patches rules

    • Takes SPIM zarr, deformed atlas segmentation, and label TSV as inputs
    • Outputs BIDS-compliant Imaris dataset directories with configurable level wildcard
  • Processing script: create_imaris_crops.py

    • Extracts bounding boxes per atlas region using ZarrNiiAtlas.get_region_bounding_box()
    • Crops image data via ZarrNii.crop()
    • Saves as Imaris format via ZarrNii.to_imaris()
  • Configuration: New CLI options --crop_labels and --crop_atlas_segs (defaults to roi22)

  • Target rule: all_imaris_crops generates level 0 crops by default

Skips generating a region if any of the cropped shape is greater than 5000.

Usage

# Generate high-res Imaris crops for specific labels
spimquant /path/to/bids /path/to/output participant \
  --crop_labels Hippocampus Cortex \
  --crop_atlas_segs roi22

Output structure follows BIDS naming:

sub-*/micr/sub-*_seg-roi22_from-ABAv3_level-0_desc-crop_SPIM.imaris/
  └── sub-{subject}_seg-roi22_label-{region}_SPIM.ims
Original prompt

similar to the create_patches rule, make a rule that will create imaris datasets (using zarrnii's to_imaris() function based on bounding boxes from zarrnii atlas get_region_bounding_box, followed by crop(). Level should be a wildcard for this rule but should be 0 by default, since the purpose is to generate high-res crops of imaris data.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add rule to create Imaris datasets from bounding boxes Add create_imaris_crops rule for high-resolution atlas region extraction Dec 8, 2025
Copilot AI requested a review from akhanf December 8, 2025 18:50
@akhanf akhanf marked this pull request as ready for review December 15, 2025 01:31
@akhanf akhanf merged commit 3e4e785 into main Dec 15, 2025
2 checks passed
@akhanf akhanf deleted the copilot/create-imaris-datasets-rule branch December 15, 2025 01:31
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