System — disk locations, Slurm batch queue and administrator warnings
The System page of Preferences holds the settings that describe
the computer 4d runs on, as opposed to the microscope or a
particular project: where the scratch disks are, how the Slurm batch
queue of a GPU cluster is reached, and how the automatic
system warning e-mails to the administrator behave. These
settings live in the user-level configuration file 4d.cfg and apply
to every project you open. The page is divided into five sections, described
below in the order in which they appear.
The numbered markers on the screenshot point to each region; the legend explains them, and the tables below list every parameter. The ? button at the right end of the System Locations title line opens this page.
1
2
3
4
5
6
| # | Region | What it is and does |
|---|---|---|
| 1 | Preferences tabs | The eight Preferences pages; System is selected here. |
| 2 | System Locations | The two scratch disks 4d’s processing scripts may use. The ? help button sits at the right end of this title line. See System Locations. |
| – | Slurm Batch Queue System | Below System Locations (not yet on the screenshot): how the Slurm cluster is reached over SSH, what one job asks for, and the shared NFS directory. See Slurm Batch Queue System. |
| 3 | Warning messages to Admin | Whether the administrator is notified by e-mail, and at which address(es). See Administrator notification. |
| 4 | Statistics that trigger a message | How many recent recordings are evaluated, and how many violations are needed before a message is sent. See When a warning is sent. |
| 5 | Thresholds | The image-quality limits that mark a recording as a mild or severe violation. See Thresholds. |
| – | Default Values | At the right end of every parameter row (not yet on the screenshot): the value 4d was installed with, and an arrow that copies it into the parameter. See the note below. |
| 6 | Close | Close the Preferences dialog. |
System Locations
Some processing scripts write large intermediate files. Instead of filling the
project directory, they can be pointed to dedicated scratch areas on faster
disks. Two such areas are configured here: SCRATCH, a large
and fast disk such as an NVMe SSD, and FASTDISK, an even
faster but typically smaller disk such as a RAM disk. Use a single dot
(.) to disable a scratch disk — the scripts then work in the
project directory instead.
| Parameter | Label | Meaning | Default |
|---|---|---|---|
SCRATCH_DISK | Faster speed SCRATCH disk | Absolute path of a fast scratch disk, for example an NVMe SSD used to speed up the reading and writing of temporary files (e.g. /mnt/scratch). | . |
FAST_DISK | Fast (smaller) FASTDISK disk | Absolute path of a super fast but typically smaller scratch disk, such as a RAM disk (e.g. /mnt/RAM_disk). | . |
Slurm Batch Queue System
Long-running image processing can be handed to a Slurm cluster: the work is cut into pieces, every piece is submitted as a Slurm job, and the results are collected again. This section holds everything a script needs for that: how the Slurm login host is reached over SSH, what resources one job asks for, and the shared NFS directory through which input, results and logs travel. The test script Slurm batch queue – test (Utilities section of the Image scripts) exercises exactly this path and is the way to check these settings; see its entry. The partition and the resources of a job (GPUs, cores, memory, time limit) are also on the SlurmQueue tab of the main window, where the cluster's nodes and your jobs on it are shown; a change made there is a change made here.
Every parameter of this section is baked into the Python scripts as a variable
of the same name, so a script reads e.g. slurm_partition directly.
The first parameter, Use the Slurm batch queue, opens the settings under it as the Run: switches of a step open theirs: turned on, they drop down under it; turned off, they are folded away. The arrow before its name opens them while the switch stays off, since the 4D Copilot uses the login host and the job resources even then.
The paths 4d is installed with are written with <myuser>, as
the note next to the section title says: 4d replaces it with your login name
when it starts, so the fields, the default values beside them and the scripts
all have your own paths, and ~/.4d/4d.cfg keeps them filled in.
The defaults suit the lab's cluster (one job per GPU on its nodes) and the job
environment described in the installation guide; elsewhere, set the partition,
the resources and the three paths to your cluster's.
| Parameter | Label | Meaning | Default |
|---|---|---|---|
slurm_enable | Use the Slurm batch queue | Master switch (y/n). Off, the scripts that know the batch queue do their work locally instead, and 4d shows nothing of the queue: the SlurmQueue tab, the blue Run on Slurm Queue button of Manual Process, Launch on Slurm Queue in the script dialog and the queue switch of the Import tab are hidden until it is switched on again. | n |
slurm_host | Slurm login host (SSH) | Host name or IP address of the machine on which sbatch, squeue and scancel are run, reached over SSH. Empty: this computer is itself a submit host and the commands run here, without SSH. | empty |
slurm_port | SSH port | TCP port of the SSH server on the login host. | 22 |
slurm_user | SSH user name | Your account on the login host. Empty: the user name you are logged in with here. | empty |
slurm_ssh_key | SSH private key file | Private key for the password-less login (ssh-keygen, then ssh-copy-id user@host). Empty: ssh uses its default keys or the ssh-agent. | empty |
slurm_ssh_password | SSH password (not recommended) | Only when no key can be used. It is handed to sshpass, which must be installed on this computer, and it is stored in clear text in ~/.4d/4d.cfg; the scripts mask it in their logs. | empty |
slurm_ssh_options | Additional SSH options | Appended to every ssh call; -J jumphost goes through a bastion. Double quotes cannot be used in the value. | -o StrictHostKeyChecking=accept-new -o ConnectTimeout=20 -o ServerAliveInterval=30 |
slurm_partition | Slurm partition | The partition (queue) the jobs go to (sbatch --partition). Empty: the cluster default. sinfo on the login host lists them. | lbem-gpus |
slurm_account | Slurm account | The accounting group charged (sbatch --account). Empty if the cluster does not use accounts. | empty |
slurm_cpus | CPU cores per job | --cpus-per-task. | 16 |
slurm_mem_gb | CPU memory per job [GB] | --mem: the main memory of the node, not that of the GPU, in gigabytes. | 60 |
slurm_gpus | GPUs per job | Graphics cards one job asks for (--gres=gpu:N); 0 asks for none. | 1 |
slurm_time | Time limit per job | Wall-clock limit in Slurm notation: minutes, HH:MM:SS or D-HH:MM:SS (--time). A job that runs longer is killed. | 01:00:00 |
slurm_sbatch_options | Additional sbatch options | Anything else for the sbatch command line, e.g. --constraint=a100 --qos=normal. Double quotes cannot be used in the value. | empty |
slurm_shared_local | Shared NFS directory, as mounted on this computer | A directory on the shared drive that this computer and all nodes can read and write. The scripts create their job folders below it (4d_slurm_jobs/…). Required for the batch queue. | /mnt/storage/data/users/<myuser> |
slurm_shared_remote | Shared NFS directory, as mounted on the cluster nodes | The same directory as the login host and the nodes see it. Empty: the same path as here. | empty |
slurm_node_setup | Environment setup on the nodes | Shell commands a job runs before it starts Python, separated by semicolons, e.g. module load cuda/12.4; source ~/miniconda3/bin/activate py4d. | source /mnt/storage/data/users/<myuser>/4d_slurm_env/py311/activate.sh |
slurm_node_python | Python command on the nodes | The interpreter the jobs run with, after the setup above. The Slurm test needs numpy, and uses the GPU through cupy when that is installed there; the ptychography step on Slurm needs what its engines import: torch and torchvision (Torchslice, GSharp, which also need periodictable), py4DSTEM and cupy (py4DSTEM), with h5py, hdf5plugin, scipy, matplotlib, mrcfile and scikit-image. The environment must lie on the shared directory or on every node: the nodes cannot see the Python environments of this computer. | /mnt/storage/data/users/<myuser>/4d_slurm_env/py311/bin/python |
slurm_poll_seconds | Queue polling interval [s] | How often a waiting script asks Slurm for the state of its jobs and reads their progress files from the shared directory. | 5 |
ssh user@host sbatch --version answers without asking for anything.
Then set the shared directory and run Slurm batch queue – test on any
image: it reports every step, the state and progress of its 16 jobs, and the reason
when a job is not accepted or delivers nothing.sbatch, squeue
and scancel run on the login host (or on this computer, when the host is
empty); the jobs run on the nodes, which must see the shared directory and must have a
Python with numpy under the command given. The login host is taken to mount the shared
directory under the same path as the nodes.Administrator notification
During automatic data collection, 4d evaluates the most recent recordings and can send an e-mail to the administrator when the data quality drops or when no new images arrive any more. The address used as the sender is defined in the notification script itself; the recipients are set here.
| Parameter | Label | Meaning | Default |
|---|---|---|---|
notify_email_admin | Notify administrator by email | Master switch (y/n). When off, no warning e-mails are sent at all. | y |
notify_email_admin_adress | Email address(es) of administrator | Full e-mail address of the administrator. Separate several addresses with commas. This value is synchronized to the project level. | name@provider.com |
When a warning is sent
A message is not sent for every single bad image. 4d looks at the last N recordings and counts how many of them violate the thresholds below. Only when enough of them do is a message sent, and a minimum interval between two messages avoids flooding the administrator’s mailbox.
| Parameter | Label | Meaning | Default |
|---|---|---|---|
notify_last_minutes | Time since last imported image [minutes] | If no new image has been imported for this many minutes, a warning is sent (data collection may have stalled). | 15 |
notify_delay_minutes | Time between two warning or error emails [minutes] | Minimum interval between two consecutive e-mails. | 60 |
notify_lastnumber | Number of last recordings to be evaluated | How many of the most recent recordings are examined (N). | 50 |
notify_limit_mild | Among these, number of mild violations to trigger message | A message is sent when at least this many of the N recordings show a mild violation. | 30 |
notify_limit_severe | Among these, number of severe violations to trigger message | A message is sent when at least this many of the N recordings show a severe violation. | 15 |
Thresholds
Each threshold classifies a recording as either a SEVERE or a Mild violation, as indicated by the prefix of its label. Severe violations (dark images, images with a black stripe) usually mean that something is wrong with the microscope or the detector; mild violations (defocus, ice, drift, astigmatism, CTF resolution) indicate poor but still usable data. All threshold values are synchronized to the project level, so a project can override them.
| Parameter | Label | A recording violates when… | Default |
|---|---|---|---|
flag_isdark_threshold | SEVERE: Image is dark, if average pixel value is below [counts] | …its mean pixel value is below this value. | 0.1 |
flag_hasstripe_threshold | SEVERE: Image has stripe, if standard deviation is above [% of mean] | …its standard deviation, as a percentage of the mean, is above this value (a black stripe or region). | 38.0 |
flag_hastoohighdefocus_threshold | Mild: Defocus upper limit [microns] | …its defocus is above this value. | 7.0 |
flag_hastoolowdefocus_threshold | Mild: Defocus lower limit [microns] | …its defocus is below this value. | 0.2 |
flag_icinesstoohigh_threshold | Mild: Iciness too high threshold [a.u.] | …its iciness value is above this value. | 1.6 |
flag_drifttoohigh_threshold | Mild: Sample drift too high threshold [Angstroms] | …its measured drift is above this value. | 50.0 |
flag_astigmatismtoohigh_threshold | Mild: Astigmatism too high threshold [microns] | …its astigmatism is above this value. | 0.03 |
flag_ctfresolutiontoobad_threshold | Mild: CTF resolution too bad threshold [Angstroms] | …the resolution of its CTF fit is worse (a larger number) than this value. | 8.0 |