4d — AutoProcessing

Parallel batch processing · 4d User Manual

← Back to the AutoProcess tab · Library page

AutoProcessing — running scripts on many datasets at once

Processing one dataset at a time in the Manual tab is right while you are working out the parameters. Once those are settled, you want the same scripts applied to everything — a whole microscope session, thousands of micrographs. That is what AutoProcess does: it takes a queue of datasets and runs your chosen scripts over them, many at a time, using all the cores of the machine.

The workflow has three steps, and they always happen in this order:

  1. Select the datasets in the Library.
  2. Choose the scripts to run on them, and submit them to the queue.
  3. Let the queue run in the AutoProcess tab, watching progress and throughput.
Everything in AutoProcess is a queue, not a batch job: you can keep adding datasets while processing runs, reprioritize what matters, and stop and resume at any point. Nothing is lost when you stop — unprocessed datasets simply stay in the queue.

Step 1 — Select the datasets in the Library

Selecting is a two-stage idea in 4d, and it is worth understanding the distinction, because it is what makes selecting thousands of datasets quick:

TermMeaning
HighlightedThe rows currently marked by the mouse — click a row, then Shift-click another to highlight a whole range, or Ctrl/Cmd-click to add individual rows. This is a transient, purely visual mouse selection.
SelectedThe rows whose checkbox in the Select column is ticked. This is the persistent selection that all processing acts on, and it survives sorting, filtering and restarts.

So the fast way to select a large number of datasets is: highlight them with the mouse (click the first, Shift-click the last — or sort by a column first so the ones you want are adjacent), then press the checkbox icon in the toolbar at the top (Select highlighted images, shortcut Space) to turn that highlight into a real, ticked selection.

The neighbouring toolbar icons cover the other common cases:

Toolbar actionShortcutWhat it does
Select highlighted imagesSpaceTick the checkbox of every row currently highlighted with the mouse — the main way to build a selection.
Remove selection from highlightedCtrl+SpaceThe inverse — untick the highlighted rows.
Select All ImagesCtrl+ATick every dataset in the project.
Deselect All ImagesCtrl+RClear the whole selection.
Invert SelectionCtrl+ISwap selected and unselected.
Show selected images onlyCtrl+XHide everything that is not ticked — a quick way to verify the selection before submitting.

The count in the top-right corner of the Library (“6946 datasets: 6946 selected and 1 highlighted” in the example below) always tells you exactly what you are about to act on. Check it before submitting — it is the difference between processing your 200 best micrographs and processing all 6946 of them.

Sort the Library by a quality column first (drift, fibril count, defocus…) and the datasets you want end up next to each other — then a single Shift-click range plus Space selects exactly them. The Auto Selection Tool in the toolbar can build such selections from parameter thresholds automatically.

Step 2 — Choose the scripts and submit to the queue

With the selection made, press Process Selected at the top-left of the Library toolbar. 4d then asks which scripts should run on those datasets, in the Scripts To Be Executed dialog:

Selecting the scripts to be executed on the selected datasets 1 2 3 4 5 6 7
#RegionWhat it is
1Library tableThe datasets of the project, one per row. Every row's Select checkbox is ticked here — the whole session is selected.
2Process SelectedThe button that starts this step: it takes every ticked dataset and opens the script dialog. Disabled while nothing is selected.
3Selection counter“6946 datasets: 6946 selected and 1 highlighted” — confirm this before continuing.
4Available scriptsThe scripts of the current section — here the Fibrils scripts: Drift-correct, Fibril Picker, Fibril Analysis, STAR file maintenance.
5Selected ScriptsWhat will actually run, in this order. Here only Fibril Picker — but several scripts can be chained, and each dataset then runs them in sequence.
6→ / ← buttonsMove scripts between the two lists.
7ContinueSubmits the datasets, with those scripts, to the processing queue. Cancel aborts without queueing anything.
The scripts run with the parameters currently stored for each dataset — the same values you would see in the Manual tab. Establish your parameters on one or two representative datasets first, then submit the whole session here; there is no opportunity to adjust parameters once the queue is running.

Step 3 — The AutoProcess queue running

Pressing Continue hands the datasets to the AutoProcess tab, which runs them. The screenshot below is a real fibril-picking run on an Ubuntu Linux workstation, part-way through the queue:

The AutoProcess tab processing a large queue in parallel 1 2 3 4 5 6 7 8 9 10 11
#RegionWhat it shows
1Jobs to run in parallelHow many datasets are processed simultaneously — 30 here. This is the single most important performance setting; see Choosing the number of parallel jobs.
2CPU / RAM / disk read-outLive resource monitoring, refreshed every second: used cores (“30 own, 31 system”, load 16.2 on 128 cores), free RAM (465.6 GB of 503.7 GB) and free disk space. Watch the RAM figure — exhausting memory is the usual reason a high job count fails.
3GPU ResourcesThe NVIDIA GPUs detected on the machine (four RTX A6000 here), each with a use checkbox so you can reserve one for other work. GPU-capable scripts distribute across the ticked GPUs; this section is absent on machines without NVIDIA GPUs.
4Run in FAST modeSets the fast_mode parameter for every script; scripts that support it then skip their more expensive optional steps.
5Processing Queue controlsAdd Images (add the current Library selection to the queue), Prioritize (move highlighted queue entries to the front), Clear All and Clear Selected.
6Images in queueThe waiting datasets, in the order they will be processed. Highlight entries here to Prioritize or Clear Selected them.
7Stop ProcessingStops after the running jobs finish; everything still queued stays queued. Press again to resume.
8Queue status“Processing, 6833 images are in queue” — the live backlog, counting down as datasets finish.
9Throughput & remaining time167.5 images/min, Remaining: 41 min. The rate is measured over a sliding 60-second window, so it reflects the current speed rather than a long-run average — expect it to fluctuate during a run — and the remaining-time estimate follows it.
10Automatically start processingWhen ticked, the queue starts by itself as soon as datasets are added — combine it with continuous import for a fully hands-off pipeline that processes data as the microscope produces it.
11Live logOne line per event per dataset: STARTING, Executing, Saving results, FINISHED. The Id column is the parallel slot, so you can follow one worker's progress through the interleaved output of all 30.

The worked example: 6900 micrographs in 45 minutes

The run shown above is fibril picking — the Fibril Picker script, including its full filter chain (binning, Hanning/Gaussian filtering, Kuwahara, bottom-hat, tubeness/Hessian scoring, and the per-candidate Fourier test) — on a complete session of about 6900 micrographs:

QuantityValue
MachineUbuntu Linux workstation, 128 CPU cores, 512 GB RAM, 4 × RTX A6000
Parallel jobs30
Throughput≈ 150 images/min (the read-out fluctuates; 167.5/min at the moment shown)
Total≈ 6900 images in ≈ 45 minutes

That is roughly 0.4 seconds per micrograph in wall-clock terms, although each individual micrograph takes on the order of ten seconds — the speed comes entirely from running 30 of them at once. Sequential processing of the same session would have taken most of a day.

The CPU read-out is worth a second look: 30 jobs, but a load average of 16.2 on a 128-core machine, and 465 GB of RAM still free. The machine is not saturated — this workload is limited by per-image work that does not parallelize inside a single job, so there is head-room here to raise the job count further. That is exactly the kind of judgement the live read-outs are there to support.

Throughput scales with the number of parallel jobs only as long as the machine can feed them. Verify the scaling on your own hardware: queue a few hundred datasets, read the throughput figure, adjust the job count, and watch how it responds.

Following progress in the Library

You do not have to stay in the AutoProcess tab. The Library table colours each dataset row by its processing state, so switching back gives an immediate overview of the whole session:

Row colourStateMeaning
BlueQueuedSubmitted and waiting — the backlog still to be processed.
YellowRunningCurrently being processed. These rows pulse gently between yellow and orange, so the active datasets are easy to spot. There are as many of them as you have parallel jobs.
WhiteDoneFinished (or never queued). The row's result columns are filled in with the values the scripts produced.
The Library table during processing, with queued, running and finished rows 1 2 3 4
#RegionWhat it shows
1Queued rows (blue)Datasets waiting in the queue.
2Running row (yellow)A dataset currently being processed by one of the parallel jobs.
3Finished rows (white)Already processed — note their last_processed timestamps are from today's run, while the queued rows still show older dates.
4Result columns filling inAs each dataset finishes, the values its scripts produced (fibril counts, scores, timestamps) appear in the table — sort by them to review the results while the rest of the queue is still running.

The AutoProcess button in the main toolbar also pulses yellow-orange while the queue is working, so you can tell processing is still running from any tab.

Choosing the number of parallel jobs

Jobs to run in parallel is capped at the number of CPU threads the machine reports, but the best value is usually lower than the maximum. Three limits decide it:

A practical approach: start at about half the core count, queue a few hundred datasets, and read the throughput figure. Raise the job count and watch whether throughput actually improves — when it stops improving, or RAM starts running low, you have found the machine's limit. The setting is remembered per project.

GPU-accelerated scripts need a different calculation: the limit is GPU memory, not system RAM, and too many concurrent jobs per GPU will fail with out-of-memory errors. Use the per-GPU use checkboxes to control which GPUs take part, and keep the job count modest for GPU workloads.

Practical notes