Skip to content

feat(ephys): carry a job's post-processing step list to the sorter - #216

Open
tabedzki wants to merge 1 commit into
masterfrom
tabedzki/feat/postprocessing-stage
Open

tabedzki wants to merge 1 commit into
masterfrom
tabedzki/feat/postprocessing-stage

Conversation

@tabedzki

@tabedzki tabedzki commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Ephys jobs can now choose a post-processing step list, built the same way as the preprocessing (PreCluster) list. The pipeline carries it to BrainCogsEphysSorters, which runs it after the sort. The two methods are spikeinterface (sorting-analyzer metrics) and bombcell (unit labels good / mua / noise / non_soma).

Changes

  • New table definitions in u19_pipeline/ephys_postcluster.py. They mirror element-array-ephys's ephys_precluster:
    • PostClusterMethod, PostClusterParamSet, PostClusterParamSteps (+ .Step) in <prefix>pipeline_ephys_element.
    • EphysPostParams (-> recording_process.Processing, -> PostClusterParamSteps) in <prefix>recording_process.
    • No existing table is altered. A job without an EphysPostParams row has no post-processing.
    • The schemas are not activated on import. ephys_postcluster.tables() returns None until the tables exist.
  • Parameter file: for every ephys job the handler now writes and transfers postprocess_paramset_<id>.json (automatic_job/ephys_postprocess_params.py, parameter_file_creator.py). It holds [{postcluster_method: params}, ...] in step order, or [] when the job chose none or the tables don't exist yet. Writing [] explicitly means a stale file left on the cluster from an earlier job id can never apply.
  • Slurm resources: post-processing job_kwargs.n_jobs counts toward the cores request, the same way the preprocessing steps do (ephys_slurm_resources.py, slurm_creator.py).
  • scripts/create_ephys_postcluster_tables.py:
    • What it does: declares the tables and inserts the spikeinterface and bombcell methods, two default paramsets and two one-step lists.
    • It is a dry run unless --create is given, and nothing in this PR runs it.

Not done here, and needs a person

  1. Create the tables: uv run python -m scripts.create_ephys_postcluster_tables --config dj_local_conf.json --create. This needs CREATE + REFERENCES on both schemas. Until then everything here is a no-op that writes [].
  2. Restart the Streamlit app afterwards so it sees the tables.
  3. U19-pipeline-matlab needs matching +pipeline_ephys_element/PostCluster*.m classes and a +recording_process/EphysPostParams.m. Note that the MATLAB PreCluster lists allow null name/desc, but these new tables declare them NOT NULL. RecordingProcessJobGUI keeps working, and the jobs it creates simply get no post-processing.
  4. Bombcell labels are not ingested into DataJoint yet. recording.DefaultParams has no post-processing column, so new recordings get no list by default; one is chosen through the website's "Rerun with different parameters".

Testing

  • uv run pytest -rs: 733 passed, 7 skipped (DB / extras only). This includes the new tests/test_ephys_postcluster.py and tests/automatic_job/test_ephys_postprocess_params.py, plus additions to the slurm-resources and missing-params tests. I rebased on current master and ran the tests again.
  • uvx prek run --all-files: passed.

Companion PRs

Any deploy order works. The sorter treats a missing file as no post-processing, and this side writes [] until the tables exist.

Ephys jobs can now select a post-processing step list, built like the
preprocessing one. New table definitions in u19_pipeline/ephys_postcluster.py:

- PostClusterMethod, PostClusterParamSet and PostClusterParamSteps (+ .Step)
  in the ephys element schema, mirroring the PreCluster tables.
- EphysPostParams in recording_process: the list a job selected.

No existing table is altered. A job without an EphysPostParams row has no
post-processing. The schemas are activated on demand and never on import.
scripts/create_ephys_postcluster_tables.py creates the tables and their
first rows (spikeinterface and bombcell). It is a dry run without --create,
and nothing in this commit runs it.

For every ephys job the pipeline now writes postprocess_paramset_<id>.json:
the selected steps as [{postcluster_method: params}, ...], or [] when none is
selected (also when the tables don't exist yet), so a stale file on the
cluster never applies. BrainCogsEphysSorters reads it. Post-processing
job_kwargs count toward the slurm cores request, the same way the
preprocessing ones do.

Assisted-by: ClaudeCode:claude-opus-5-5
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.

1 participant