crop-zarr: keep one object's area of a zarr

crop-zarr: keep one object's area of a zarr

crop-zarr makes a copy of a series' zarr that keeps only the area around one object and turns everything else black. It uses PyReconstruct's own cropping script.

📐 Same size, same place

The images keep their full size, so the crop lines up with your series. Anything you trace on the crop lines up with the full zarr too.

🪶 Much smaller

Black areas are not even stored, so a crop is a small fraction of the original. Easy to copy to a laptop or share.

🔒 Original untouched

crop-zarr only reads the original zarr. The crop is a new folder.

New here? Start with Zarr tools on khlabgpu1: connecting, the job list, copying, and troubleshooting.

Save your series in PyReconstruct first. crop-zarr reads the saved .jser file. Changes you have not saved are not included.


1. Start it

On khlabgpu1, type:

crop-zarr

If you already have jobs, it shows your job list first; type c to crop. It asks four questions, then shows a summary before anything starts.

The four questions and the Ready to crop box.

Step

What to give it

Good to know

Step

What to give it

Good to know

STEP 1 the series

The series file (.jser). Press Tab to finish names, or paste a path.

It shows how many sections and objects the series has. A big series takes a few seconds to read.

STEP 2 the object

The name of the object to keep, for example d001.

Press Tab to finish a name, or type ? to list them. Capital letters do not matter, and a typo gets a "did you mean" suggestion. Sections without the object keep the image inside the nearest section's window, so the area stays in view above and below the object.

STEP 3 the space around it

How far past the object's outer edges to keep, in microns (µm). 0 keeps just the box around the object.

The screen shows how many pixels 1 µm is in your series.

STEP 4 the zarr, and where the crop goes

It finds the zarr your series uses; press Enter to accept the suggested folder or type another.

The crop is named after the zarr and object, for example MyZarr_d001_crop-zarr. If one with that name exists, you must type REPLACE first.

Zarr on khlabfiles? crop-zarr then suggests your folder on khlabgpu1, /data/data6/<your username>, instead of next to the zarr. Writing a crop onto khlabfiles can take hours; on khlabgpu1 a 276-section crop took about 2 minutes. If you need the crop on khlabfiles, copy its one-file .tar there afterwards.


2. While it runs

The live progress screen, with sections done and the time left.
  1. Crop the zarr, section by section.

  2. Make the one-file .tar copy, written beside the crop.

Close the window whenever you like. Type crop-zarr again to see your jobs.


3. When it is done

The Done screen: where the crop is, how to open it, and how to copy it to your own computer.
  • Look at it: open the series in PyReconstruct, then Series > Images > Find/change image directory, and pick the crop. Switch back the same way to the original zarr.

  • Copy it: press c for step-by-step help, or see Copying a zarr somewhere else.

  • In the folder: the crop, its .tar, a HOW-TO-COPY.txt, and a RUN-LOG.txt (which object, how much space, from which zarr, who ran it and when). Inside the crop: a crop_log.txt that lists every section that was filled in, made gray, or kept whole.


How long it takes

Real numbers from one series on khlabgpu1: 276 sections, the object on 232 of them, 2.5 µm kept around it, the zarr read from khlabfiles.

Where the crop is written

Crop time

Files written

Where the crop is written

Crop time

Files written

NOW khlabgpu1 (/data/data6/...)

about 2 min

about 10,000

UNTIL OCT 6, 2026 khlabgpu1, when crops still stored the black areas

about 12 min

about 120,000

AVOID onto khlabfiles, with the old crop

about 2.5 h (estimated)

about 466 per section

The newer crop simply does not store the all-black pieces, which read back as black anyway. Old and new crops of this series were compared image by image (864 images, no differences): same pixels, same image size, same coordinates, so work traced on a crop still lines up with the full zarr.