# Recorder module

## Main module

Software made for recording velocity form a Femto-Gramophone in a triggered manner. Can be used in conjunction with two-photon microscoppes by Femtonics Inc.

class `Recorder.Recorder.``Reader`(gram, frequency)

  A worker that can continnously send commands to the Gramophone with a given frequency.

  Parameters: | name (str) – The name of this reader. Can be used for identification to stop a specific reader. read_func (function) – The read function that should be called. frequency (float) – The frequency at which the function should be called in Hz.

  `read`()

    Start calling the read function repeatedly. Slot for a QThread.

class `Recorder.Recorder.``VelLogModel`(log, parent=None)

  QT modell for velocity logs. Used to make an interface between the GUI’s table view and the Velocity log object

  `add_record`(record)

    Adds the given Record object the the current velocity log.

  `columnCount`(parent)

    Return the number of columns to be displayed. One column for each header.

  `data`(index, role)

    Called to receive information about a cell of the table.

  `flags`(index)

    Returns flag to decide which cells are editable.

  `headerData`(section, orientation, role)

    Returns the haeder data the GUI is asking for.

  `plot_record`(selection)

    Plots the selected record(s) using Matplotlib.

  `removeRows`(row, count, parent=<PyQt5.QtCore.QModelIndex object>)

    Removes ‘count’ number of rows starting at ‘row’

  `rowCount`(parent)

    Return the number of rows to be displayed. one row for each recording.

  `setData`(index, value, role=2)

    Called to set the data in a cell of the table.

class `Recorder.Recorder.``aboutWindow`(*args, **kwargs)

  The window shown if the user clicks the About option in the Help menu. Displays basic info about the software.

class `Recorder.Recorder.``deviceInfoWindow`(gram, *args, **kwargs)

class `Recorder.Recorder.``licenseWindow`(*args, **kwargs)

  The window shown if the user clicks the License option in the Help menu. Displays the open source license the software is distributed under.

class `Recorder.Recorder.``pyGramWindow`(devmode, log_file, *args, **kwargs)

  The main window of the Gramophone reader.

  `closeEvent`(event)

    The built in close event of QMainWindow. User is trying to close the program. Ignore the passed event if you want to stop the user from doing so.

  `connect`()

    Connects to the currently selected Gramophone.

  `connect_btn_cb`()

    Callback for the connect button.

  `delete_btn_cb`()

    Callback for the Delete button.

  `delete_warning`(count)

    Displays a message box to ask for confirmation. Call it if the user is trying to delete velocity records.

  `disconnect`()

    Disconnects the currently connected Gramophone.

  `gramophone_error`(error_message)

    Slot for the errorOccurred signal of the Gramophone. Displays a message box with the warning, disconnects if necessary.

  `log_changed`()

    Calll this function when the velocity log is modified and it should be saved.

  `make_dummy`()

    Function only available for developers. Creates a dummy record in the current velocity log with randomized data.

  `new_file`()

    Creates a new blank velocity log file and sets it as the current working file.

  `new_window`()

    Opens a new instance of the Gramophone recorder. New windows can be used for simultanious recording of an other Gramophone device.

  `open`()

    Opens a velocity log from file and sets it as the current working file.

  `plot_btn_cb`()

    Callback for the Plot button.

  `quit`()

    Close all windows and disconnrect form the Gramohone. Call this right before exiting.

  `record_warning`()

    Displays a warning if the recording is in progress. Call it if the user tries to exit.

  `refresh_gram_list`()

    Refreshes the list of available Gramophones.

  `reset_gram_timer`()

    Function only available for developers. Sends a Reset internal clock command to the Gramophone.

  `reset_graph`()

    Resets the live velocity plot to its starting state ie. erases the plot if there is already something on it.

  `save`()

    Saves the currently used log file. Returns True if the file is saved or False if saving was cancelled

  `save_as`()

    Same as save, but shows a file selection dialog to save to an other file.

  `save_warning`()

    Displays a warning if there are unsaved changes to the log file. Call it if the user tries to exit.

  `select_file`(mode='save', filename=None)

    Displays a file selection dialog for velocity log files. Mode can be ‘save’ or ‘open’.

  `selected_rows`

    A property that holds a list of the selected rows of the current velocity log.

  `set_autosave`(val)

    Turns automatic saving on (True) or off (False)

    Parameters: | val (bool) – The sate to set

  `show_about`()

    Displays the About window.

  `show_license`()

    Displays the License window.

  `show_manual`()

    Opens the Gramophone User Guide in the default pdf reader.

  `show_settings`()

    Opens a settings window.

  `update_conn_state`()

    Updates the GUI depending on wheter the software is currently connected to a Gramophone.

  `update_graph`(velocity)

    Slot for the vel_signal of the Gramophone. Shifts the graph to the right and appends with the value received.

  `update_rec_state`(in_state_1, in_state_2)

    Slot for the rec_signal of the Grmaophone. Updates the state of recording and the GUI.

  `update_table_size`()

    Update all except last the row’s width to fit content in the list of velocity recordings.

  `update_timer`(millis)

    Slot for the time_signal of the Gramophone. Updates the timer on the GUI.

  `update_title`()

    Updates the tile of the window with the name of the current file and a * character if there are unsaved changes made to said file. Called after the current file is changed or saved.

class `Recorder.Recorder.``settingsWindow`(main_win, *args, **kwargs)

## Logging module

Module for logging Velocity data form the Gramophone into HDF5 files.

class `logger.``DummyRecord`

  A record with random data insted of recorded velocity. Can be used for testing purposes.

class `logger.``FileRecord`(file_group)

  A velocity record that is saved in a HDF5 file.

  `comment`

    Returns the record’s comment form file

  `device_serial`

    Returns the record’s device id form file

  `finish_time`

    Returns the finish time form file

  `mean_vel`

    Returns the record’s mean velocity form file

  `rec_id`

    Returns the record’s ID form file

  `sampling_freq`

    Returns the record’s mean velocity form file

  `save`(log_file)

    Saves the modified fields and returns itself.

  `software_version`

    Returns the record’s device id form file

  `start_time`

    Returns the start time form file

  `times`

    Returns the time data form file

  `velocities`

    Returns the velocity data form file

class `logger.``MemoryRecord`(rec_id, sampling_freq, device_serial)

  A velocity record that is in memory ie. not saved yet.

  `append`(gtime, vel, rec)

    Appends this record with the given time and velocity if the recording state is 1.

  `finish`()

    Called then the recording to this record is finished. Saves the current time as the finish time.

  `start`()

    Called when recording to this record is started. Saves the current time as the start time.

class `logger.``Record`

  Abstract class for velocity records.

  `date_hr`

    A property that holds the starting date in a human readable format defined by the data_format class variable.

  `finish_time_hr`

    A property that holds the finishing time in a human readable format defined by the time_format class variable.

  `length`

    A property that holds the length of this recording in seconds.

  `length_hr`

    A property that holds the length of the recording in a human readable format defined by the length_format class variable.

  `mean_vel`

    A property that holds the mean of the recorded velocities.

  `save`(log_file)

    Saves this record into a file and returns a FileRecord that can replace it.

    Parameters: | log_file (h5py.File) – An opened HDF5 file

  `start_time_hr`

    A property that holds the starting time in a human readable format defined by the time_format class variable.

  `unique_id`

    A property that stores a unique id based on the start time of this record. Used for naming folders in the HDF5 file.

class `logger.``VelocityLog`

  A container object for velocity recordins. Handles saving records to HDF5 files.

  `save`()

    Saves all records from this log to file.

## Output

- Velocity data
- Metadata