Skip to content

Add DANDI API key selection and a Slack notification toggle - #2

Open
nmarkowitz wants to merge 70 commits into
lincbrain:masterfrom
nmarkowitz:feat/config-api-keys
Open

nmarkowitz wants to merge 70 commits into
lincbrain:masterfrom
nmarkowitz:feat/config-api-keys

Conversation

@nmarkowitz

Copy link
Copy Markdown

This branch accomplishes two things

  1. Allows user to select api keys to use in the project so different users can upload data
  2. Update pytests. Some, involving prefect or docker, are moved to github tasks so running docker and prefect natively is not required

@nmarkowitz
nmarkowitz marked this pull request as ready for review September 10, 2026 14:12
nmarkowitz and others added 22 commits September 11, 2026 12:05
…tput' into fix/psoct-processing

# Conflicts:
#	opticstream/data_processing/stitch/fiji.py
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scanners that number output continuously (spectral_0001.nii, ...) with no
slice or acquisition in the name previously had every file pinned to one
mosaic, so tiles past the first mosaic became phantom batches 23, 24, ...
and the next mosaic never started.

- Add AcquisitionSequence: maps an image number to slice, mosaic and tile.
  Each mosaic holds grid_size_x * grid_size_y tiles (normal/tilted grids),
  tiles are renumbered from 1, and after the slice's last mosaic the
  sequence moves to mosaic 1 of the next slice. Placement depends only on
  the image number, so restarting the watcher is safe.
- watch: when filename_pattern has no {slice}/{acquisition}, use the
  sequence, with --slice/--mosaic (default 1/1) giving where image 1
  starts. --mosaic is now the position within the slice (1 = normal,
  2 = tilted) instead of a global mosaic id; --acquisition remains an
  optional alternative.
- Never dispatch a batch number beyond a mosaic's grid_size_x.
- Enface previews follow the same sequence (per-mosaic image offset and
  acquisition label from acquisition_mosaic_map), share one folder listing
  per poll, and drop finished mosaics once the next one has started.
- Docs and tests updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nmarkowitz and others added 13 commits October 21, 2026 15:58
grid_size_x counts batches, which are grid columns; grid_size_y counts tiles per
batch, which are grid rows. This matches the snake-by-columns, up-right order
used by the stitcher, the previews, and the BIDS sidecars.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each sidecar now records ChunkNumber, ColNumber and RowNumber (1-based, the same
grid cell as ChunkTransformationMatrix), Acquisition (the acquisition_mosaic_map
label) and SliceNumber.

Default JSONParams.SampleFixation to "mineral oil". The docs defaults table
now also shows the 1.42 refractive index. Tests read defaults from JSONParams
instead of hard-coding them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ops oct setup and ops lsm setup now select the "dandi-api-key" Secret block when
--dandi is not given. If that default block is missing, setup warns and leaves
the field unset. An explicitly named block that is missing still fails. Pass
--dandi "" to leave it unset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sets json_params.BodyPartDetails, written as BodyPartDetails in the BIDS
sidecars. When omitted, the JSONParams default applies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The acquisition software rewrites filenames.csv while scanning, and a read
from the watcher could stop it from reaching the file. Tiles are placed by
image number alone, so drop acquisition_csv and test that the watcher never
opens the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fiji stitching, acquisition previews and BIDS sidecar tile positions now
assume the acquisition grid is traversed snake-by-rows starting left-down.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the block's delete_spectral_after_previews switch on (default off),
the new delete-slice-spectral flow removes a slice's raw spectral tiles
once every mosaic's full-acquisition preview has finished and, when
archive_path is set, every tile has an archive copy with its .sha256 and
no batch of the slice is being re-archived. It runs after each
acquisition preview and each batch archive, so whichever finishes last
deletes the files. Enface maps are kept, and MATLAB processing and DANDI
uploads are not waited for.

Finished previews record their input folder, acquisition label and image
range in mosaic_NNN_progress.json, so only that mosaic's spectral files
are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings mosaic2d's angle_to_rgb with an orientation colour wheel and
angle_units, used by the acquisition enface previews.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mosaic2d now writes just the JPEG that is posted to Slack; no stitched
NIfTI is produced, even in scratch. Orientation previews come straight
from mosaic2d's angle colouring with its colour wheel instead of being
redrawn from the NIfTI, and angles are read in degrees: radian maps
(acquisition.orientation_units) are passed as angle_units="rad" for
mosaic2d to convert. Only non-NIfTI tiles are still copied to a scratch
NIfTI before stitching.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tilted acquisitions overlap more between batches than normal ones (e.g.
42% along X, 20% along Y), so the single acquisition.tile_overlap is
replaced by tile_overlap_x_normal, tile_overlap_y_normal,
tile_overlap_x_tilted and tile_overlap_y_tilted (defaults 20, 20, 42,
20 percent). X is between batches, Y within a batch. Blocks saved with
tile_overlap load with it as the normal X/Y overlap.

MosaicContext.tile_overlap() picks the mosaic's pair. Acquisition
previews pass it to generate_tile_config and mosaic2d, BIDS sidecar step
sizes use it, and Fiji, which takes one overlap, gets the larger value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stitches the enface maps of an M x N grid (--rows tiles per strip,
--columns strips) from a folder into JPEGs in --out-dir with the same
mosaic2d path as acquisition previews, using the project block's naming,
overlaps, pixel size and orientation units but not its grid, state or
project folders. --tilted, --start-image, --modalities, --watch
(re-stitch as tiles arrive, exit when complete), --slack and --open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the inline deletion after previews and archives with
sweep-spectral-cleanup, served every 5 minutes for a project. A slice's
spectral files are deleted only once its acquisition previews and
archives are done, every state milestone the block enables (MATLAB
processing, stitching, registration, DANDI uploads) is set with nothing
running or failed, and no Prefect flow run referring to the slice is
active or ended within 2 minutes.

Milestone fields without a rule in MILESTONE_RULES block deletion (and
fail a test), and the flow-run check covers flows added later. Deleted
slices get a spectral_deleted.json marker and are skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@kabilar kabilar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @nmarkowitz. I will provide my comments below.

cc @balbasty @ayendiki @satra

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please remove all files under opticstream.egg-info/ and add *.egg-info/ to .gitignore.

Comment thread .env

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would suggest adding this to the .gitignore so that it is not tracked.

@kabilar

kabilar commented Nov 20, 2026

Copy link
Copy Markdown
Member

Hi @nmarkowitz, I am not too familiar with this repo so if you want to self-merge after addressing my comments above that is fine.

This branch accomplishes two things

  1. Allows user to select api keys to use in the project so different users can upload data
  2. Update pytests. Some, involving prefect or docker, are moved to github tasks so running docker and prefect natively is not required

As an aside, it's a bit difficult to review given the breadth of changes in this pull request. In addition to the items listed above, there also seems to be changes to the Slack notification, etc.

Thanks.

@kabilar kabilar changed the title Feat/config api keys Add DANDI API key selection and a Slack notification toggle Nov 20, 2026
@nmarkowitz

Copy link
Copy Markdown
Author

@kabilar I've edited this repo well beyond this. I eventually came to the conclusion that choosing an api key to use from many for a single instance is silly. There's far more changes now in a separate branch (maybe a branch of this branch) that isn't a draft PR. There's been a lot of work over the months. I need to think about how to manage this going forward because I've been editing it as for a separate system rather than to be used across all system. The version currently running on dual-system has many uncommitted and unpushed changes. Basically it's a massive mess and would take some time to unify everything. I'll try coming up with a plan and let you know a way to go forward. One PR/commit/branch that does need to happen is what the current version is being used.

nmarkowitz and others added 11 commits November 30, 2026 09:16
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Batch: BATCH_READY -> archive -> BATCH_ARCHIVED -> DANDI upload (dandi_uploaded).
Mosaic: watcher emits MOSAIC_READY -> en-face stitch + Slack -> MOSAIC_ENFACE_STITCHED.
Slice: SLICE_READY once all mosaics are stitched. Direct mode, watch-enface and the
MATLAB-only config fields are removed; old blocks and state still load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep feat/no-matlab's docker-compose.yaml; the branch's other commits were
already merged through fix/psoct-processing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fit-optic-axis-3d-slice runs PSOCTRec (Julia) on a slice's en-face tiles once every
mosaic is in: stitch, register tilted to normal, 3D axis, DEC map. Tiles are found as
the acquisition previews found them (recorded input folder, acquisition label and
image offset, through filename_pattern / filename_modality_map) and passed to the
packaged run_3daxis.jl as tiles.tsv / settings.tsv.

- data_processing/optic_axis_3d/run_3daxis.jl: port of octacq_linux/run_3daxis_from_octacq.jl
  reading the job files; tilt from mechanical_tilt_deg, tiles per column from the grid
- config: optic_axis_3d section (off by default); biref modality, processed_biref label
- state: slice milestone optic_axis_3d; event SLICE_OPTIC_AXIS_3D
- spectral cleanup does not wait for the fit (it reads only en-face maps)
- preview helpers take an optional modalities set
- served by ops oct serve all; docs and tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

3 participants