4d — System

Preferences ▸ System · 4d User Manual

← Back to Preferences

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.

The System preferences page with numbered regions 1 2 3 4 5 6
#RegionWhat it is and does
1Preferences tabsThe eight Preferences pages; System is selected here.
2System LocationsThe 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 SystemBelow 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.
3Warning messages to AdminWhether the administrator is notified by e-mail, and at which address(es). See Administrator notification.
4Statistics that trigger a messageHow many recent recordings are evaluated, and how many violations are needed before a message is sent. See When a warning is sent.
5ThresholdsThe image-quality limits that mark a recording as a mild or severe violation. See Thresholds.
–Default ValuesAt 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.
6CloseClose the Preferences dialog.
Each row shows the parameter’s label and its current value. Edit the value in place; it is saved to your user configuration when you leave the field. Hover a label to see the parameter’s explanation (the LEGEND text of the entry).
As on the Manual Processing tab, a grey field at the right end of each row, under the heading Default Values, shows the value 4d was installed with, in a lighter grey while the parameter holds that value. The arrow button left of it copies the default into the parameter. After a copy the arrow turns into a cross (Undo): click it, or press Command-Z or Control-Z, to put the value from before back. Only the last copy can be undone, and only while the parameter still holds the default.

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.

ParameterLabelMeaningDefault
SCRATCH_DISKFaster speed SCRATCH diskAbsolute 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_DISKFast (smaller) FASTDISK diskAbsolute 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.

ParameterLabelMeaningDefault
slurm_enableUse the Slurm batch queueMaster 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_hostSlurm 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_portSSH portTCP port of the SSH server on the login host.22
slurm_userSSH user nameYour account on the login host. Empty: the user name you are logged in with here.empty
slurm_ssh_keySSH private key filePrivate 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_passwordSSH 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_optionsAdditional SSH optionsAppended 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_partitionSlurm partitionThe partition (queue) the jobs go to (sbatch --partition). Empty: the cluster default. sinfo on the login host lists them.lbem-gpus
slurm_accountSlurm accountThe accounting group charged (sbatch --account). Empty if the cluster does not use accounts.empty
slurm_cpusCPU cores per job--cpus-per-task.16
slurm_mem_gbCPU memory per job [GB]--mem: the main memory of the node, not that of the GPU, in gigabytes.60
slurm_gpusGPUs per jobGraphics cards one job asks for (--gres=gpu:N); 0 asks for none.1
slurm_timeTime limit per jobWall-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_optionsAdditional sbatch optionsAnything else for the sbatch command line, e.g. --constraint=a100 --qos=normal. Double quotes cannot be used in the value.empty
slurm_shared_localShared NFS directory, as mounted on this computerA 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_remoteShared NFS directory, as mounted on the cluster nodesThe same directory as the login host and the nodes see it. Empty: the same path as here.empty
slurm_node_setupEnvironment setup on the nodesShell 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_pythonPython command on the nodesThe 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_secondsQueue 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
Set the login host, user and key first, then check from a terminal that 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.
Where things run. 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.

ParameterLabelMeaningDefault
notify_email_adminNotify administrator by emailMaster switch (y/n). When off, no warning e-mails are sent at all.y
notify_email_admin_adressEmail address(es) of administratorFull 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.

ParameterLabelMeaningDefault
notify_last_minutesTime 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_minutesTime between two warning or error emails [minutes]Minimum interval between two consecutive e-mails.60
notify_lastnumberNumber of last recordings to be evaluatedHow many of the most recent recordings are examined (N).50
notify_limit_mildAmong these, number of mild violations to trigger messageA message is sent when at least this many of the N recordings show a mild violation.30
notify_limit_severeAmong these, number of severe violations to trigger messageA 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.

ParameterLabelA recording violates when…Default
flag_isdark_thresholdSEVERE: Image is dark, if average pixel value is below [counts]…its mean pixel value is below this value.0.1
flag_hasstripe_thresholdSEVERE: 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_thresholdMild: Defocus upper limit [microns]…its defocus is above this value.7.0
flag_hastoolowdefocus_thresholdMild: Defocus lower limit [microns]…its defocus is below this value.0.2
flag_icinesstoohigh_thresholdMild: Iciness too high threshold [a.u.]…its iciness value is above this value.1.6
flag_drifttoohigh_thresholdMild: Sample drift too high threshold [Angstroms]…its measured drift is above this value.50.0
flag_astigmatismtoohigh_thresholdMild: Astigmatism too high threshold [microns]…its astigmatism is above this value.0.03
flag_ctfresolutiontoobad_thresholdMild: CTF resolution too bad threshold [Angstroms]…the resolution of its CTF fit is worse (a larger number) than this value.8.0
These thresholds are also used to color the quality flags of each recording in the Library, so tightening or loosening them here changes both the warning e-mails and what you see as flagged in the image list.