cibrrig.archiving.backup ======================== .. py:module:: cibrrig.archiving.backup .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: cibrrig.archiving.backup._log cibrrig.archiving.backup.DEFAULT_SUBJECTS_PATH cibrrig.archiving.backup.DEFAULT_SESSION_PATH cibrrig.archiving.backup.DEFAULT_VIDEO_DIRECTORY Classes ------- .. autoapisummary:: cibrrig.archiving.backup.Archiver cibrrig.archiving.backup.RecordingInfoUI Functions --------- .. autoapisummary:: cibrrig.archiving.backup.main cibrrig.archiving.backup.archive cibrrig.archiving.backup.no_gui Module Contents --------------- .. py:data:: _log .. py:data:: DEFAULT_SUBJECTS_PATH .. py:data:: DEFAULT_SESSION_PATH .. py:data:: DEFAULT_VIDEO_DIRECTORY .. py:class:: Archiver(keep_raw) Handles the backup of electrophysiological and related session data for a given subject. .. attribute:: keep_raw Whether to keep raw data after compression. :type: bool .. attribute:: subject_ID ID of the subject being backed up. :type: str .. attribute:: ephys_files_local Local electrophysiological files to back up. :type: list .. attribute:: ephys_files_remote Remote electrophysiological files to back up. :type: list .. attribute:: num_sessions Number of local sessions found for the subject. :type: int .. attribute:: subjects_path Path where the subjects' data is stored remotely. :type: Path .. attribute:: run_path Path to the local session data. :type: Path .. attribute:: today_path Path to the backup directory based on the record date. :type: Path .. attribute:: video_files List of video files found in the sessions. :type: list .. py:attribute:: subject_ID :value: None .. py:attribute:: ephys_files_local :value: None .. py:attribute:: ephys_files_target :value: None .. py:attribute:: has_imec :value: False .. py:attribute:: has_nidq :value: False .. py:attribute:: has_video :value: False .. py:attribute:: has_audio :value: False .. py:attribute:: has_log :value: False .. py:attribute:: has_notes :value: False .. py:attribute:: has_insertions :value: False .. py:attribute:: num_sessions :value: 1 .. py:attribute:: subjects_path_target .. py:attribute:: subject_path_target :value: None .. py:attribute:: run_path_source .. py:attribute:: record_date :value: None .. py:attribute:: today_path_target :value: None .. py:attribute:: keep_raw .. py:attribute:: video_files :value: None .. py:attribute:: video_path_target :value: None .. py:attribute:: session_list_source :value: None .. py:method:: set_subjects_path(path) Set the path where the subjects' data will be archived. .. py:method:: get_sessions_local() Find local sessions to back up. .. py:method:: guess_subject_ID() Infer the subject ID from the local session path. .. py:method:: get_ephys_files_remote() Retrieve remote electrophysiological files to be backed up. .. py:method:: get_ephys_files_local() Retrieve local electrophysiological files. .. py:method:: compress_ephys_files_local() Compress local electrophysiological files before copying to archive. .. py:method:: compress_ephys_files_remote() Compress remote electrophysiological files. .. py:method:: get_record_date() Get the recording date from the metadata of local electrophysiological files. .. py:method:: make_rec_date_target() Create the target directory for the backup, named by the record date. .. py:method:: copy_sessions() Copy session data from the local to the target directory. .. py:method:: copy_sessions_alf() Compress any video files in the sessions. .. py:method:: compress_video_in_place() Compress any video files in the sessions. .. py:method:: get_videos_in_sessions() Find video files in the local session directories. .. py:method:: mark_backup() Create a flag file in each session directory to indicate the backup date. .. py:method:: copy_run_level_files() Copy files in the run folder to the backup location .. py:method:: full_archive() Chain all the methods to perform a full archive .. py:method:: full_archive_with_local_compression() Chain all the methods to perform a full archive with local compression first .. py:class:: RecordingInfoUI(archiver, title) Bases: :py:obj:`PyQt5.QtWidgets.QWidget` GUI to ask the user for the destination (Subjects path), source (run_path), and subject_ID (spikeglx run name). .. attribute:: archiver Instance of the `Archiver` class to manage the backup. :type: Archiver .. py:attribute:: archiver .. py:method:: init_ui(title) Set up the UI layout and widgets. .. py:method:: browse_subjects_clicked() Open a dialog for the user to select the subjects path. .. py:method:: browse_run_clicked() Open a dialog for the user to select the local run path. .. py:method:: set_clicked() Set the paths and subject ID from the user input. .. py:method:: open_file_dialog() .. py:method:: update_has_video_state(state) .. py:function:: main(local_run_path, remote_subjects_path, keep_raw, no_local_compression) 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. :param local_run_path: Path to the local recording session. :type local_run_path: str :param remote_subjects_path: Path to the remote storage location. :type remote_subjects_path: str :param keep_raw: Flag to indicate whether raw data should be kept after compression. :type keep_raw: bool :param no_local_compression: If True, use legacy remote compression behavior. :type no_local_compression: bool .. py:function:: archive(keep_raw) Run the backup process with a GUI. :param keep_raw: Whether to keep raw data after compression. :type keep_raw: bool .. py:function:: no_gui(local_run_path, remote_subjects_path, compress_locally=True) Run the backup process without a GUI, using command line arguments. :param local_run_path: Path to the local recording session. :type local_run_path: str :param remote_subjects_path: Path to the remote storage location. :type remote_subjects_path: str :param compress_locally: If True, compress files locally before copying. Defaults to True. :type compress_locally: bool