cibrrig.archiving.backup

This module provides functionality to backup raw electrophysiological data to a specified folder. The backup is a “Frozen copy” that should be identical to the data acquired on the day of recording.

Much of the functionality of the Archiver class is deprecated but retained for legacy support.

Key features: - Handles electrophysiological (ephys), video, audio, and metadata files. - Compresses electrophysiological files using SpikeGLX, optionally removing the raw data after compression. - Supports GUI-based file selection using PyQt5 for the backup process. - Supports running the backup without a GUI through the command line. - Copies the session data to a new target location based on the recording date. - Marks the backup with a timestamp indicating when it was archived.

Attributes

_log

DEFAULT_SUBJECTS_PATH

DEFAULT_SESSION_PATH

DEFAULT_VIDEO_DIRECTORY

Classes

Archiver

Handles the backup of electrophysiological and related session data for a given subject.

RecordingInfoUI

GUI to ask the user for the destination (Subjects path), source (run_path), and subject_ID (spikeglx run name).

Functions

main(local_run_path, remote_subjects_path, keep_raw, ...)

Entry point for the backup process.

archive(keep_raw)

Run the backup process with a GUI.

no_gui(local_run_path, remote_subjects_path[, ...])

Run the backup process without a GUI, using command line arguments.

Module Contents

cibrrig.archiving.backup._log[source]
cibrrig.archiving.backup.DEFAULT_SUBJECTS_PATH[source]
cibrrig.archiving.backup.DEFAULT_SESSION_PATH[source]
cibrrig.archiving.backup.DEFAULT_VIDEO_DIRECTORY[source]
class cibrrig.archiving.backup.Archiver(keep_raw)[source]

Handles the backup of electrophysiological and related session data for a given subject.

keep_raw[source]

Whether to keep raw data after compression.

Type:

bool

subject_ID[source]

ID of the subject being backed up.

Type:

str

ephys_files_local[source]

Local electrophysiological files to back up.

Type:

list

ephys_files_remote

Remote electrophysiological files to back up.

Type:

list

num_sessions[source]

Number of local sessions found for the subject.

Type:

int

subjects_path

Path where the subjects’ data is stored remotely.

Type:

Path

run_path

Path to the local session data.

Type:

Path

today_path

Path to the backup directory based on the record date.

Type:

Path

video_files[source]

List of video files found in the sessions.

Type:

list

subject_ID = None[source]
ephys_files_local = None[source]
ephys_files_target = None[source]
has_imec = False[source]
has_nidq = False[source]
has_video = False[source]
has_audio = False[source]
has_log = False[source]
has_notes = False[source]
has_insertions = False[source]
num_sessions = 1[source]
subjects_path_target[source]
subject_path_target = None[source]
run_path_source[source]
record_date = None[source]
today_path_target = None[source]
keep_raw[source]
video_files = None[source]
video_path_target = None[source]
session_list_source = None[source]
set_subjects_path(path)[source]

Set the path where the subjects’ data will be archived.

get_sessions_local()[source]

Find local sessions to back up.

guess_subject_ID()[source]

Infer the subject ID from the local session path.

get_ephys_files_remote()[source]

Retrieve remote electrophysiological files to be backed up.

get_ephys_files_local()[source]

Retrieve local electrophysiological files.

compress_ephys_files_local()[source]

Compress local electrophysiological files before copying to archive.

compress_ephys_files_remote()[source]

Compress remote electrophysiological files.

get_record_date()[source]

Get the recording date from the metadata of local electrophysiological files.

make_rec_date_target()[source]

Create the target directory for the backup, named by the record date.

copy_sessions()[source]

Copy session data from the local to the target directory.

copy_sessions_alf()[source]

Compress any video files in the sessions.

compress_video_in_place()[source]

Compress any video files in the sessions.

get_videos_in_sessions()[source]

Find video files in the local session directories.

mark_backup()[source]

Create a flag file in each session directory to indicate the backup date.

copy_run_level_files()[source]

Copy files in the run folder to the backup location

full_archive()[source]

Chain all the methods to perform a full archive

full_archive_with_local_compression()[source]

Chain all the methods to perform a full archive with local compression first

class cibrrig.archiving.backup.RecordingInfoUI(archiver, title)[source]

Bases: PyQt5.QtWidgets.QWidget

GUI to ask the user for the destination (Subjects path), source (run_path), and subject_ID (spikeglx run name).

archiver[source]

Instance of the Archiver class to manage the backup.

Type:

Archiver

archiver[source]
init_ui(title)[source]

Set up the UI layout and widgets.

browse_subjects_clicked()[source]

Open a dialog for the user to select the subjects path.

browse_run_clicked()[source]

Open a dialog for the user to select the local run path.

set_clicked()[source]

Set the paths and subject ID from the user input.

open_file_dialog()[source]
update_has_video_state(state)[source]
cibrrig.archiving.backup.main(local_run_path, remote_subjects_path, keep_raw, no_local_compression)[source]

Entry point for the backup process.

If no arguments are provided, the GUI will open. If both local_run_path and remote_subjects_path are provided, the process will run without the GUI.

Parameters:
  • local_run_path (str) – Path to the local recording session.

  • remote_subjects_path (str) – Path to the remote storage location.

  • keep_raw (bool) – Flag to indicate whether raw data should be kept after compression.

  • no_local_compression (bool) – If True, use legacy remote compression behavior.

cibrrig.archiving.backup.archive(keep_raw)[source]

Run the backup process with a GUI.

Parameters:

keep_raw (bool) – Whether to keep raw data after compression.

cibrrig.archiving.backup.no_gui(local_run_path, remote_subjects_path, compress_locally=True)[source]

Run the backup process without a GUI, using command line arguments.

Parameters:
  • local_run_path (str) – Path to the local recording session.

  • remote_subjects_path (str) – Path to the remote storage location.

  • compress_locally (bool) – If True, compress files locally before copying. Defaults to True.