Setup.SetupOneDevice package

Submodules

Setup.SetupOneDevice.Setup_8206HR module

class Setup.SetupOneDevice.Setup_8206HR.Setup8206HR

Bases: SetupInterface

Setup_8206HR provides the setup functions for an 8206-HR POD device.

_bucketAccess

Dictionary with device number keys and Bucket values. This is updated in _StreamThreading() and cleared in StopStream().

Type:

dict[int,Bucket]

static GetDeviceName() str

Returns the name of the 8206-HR POD device.

Returns:

8206-HR.

Return type:

str

StopStream() None

Write a command to stop streaming data to all POD devices.

static _ChoosePreampGain() int

Asks user for the preamplifier gain of their POD device.

Returns:

Integer 10 or 100 for the preamplifier gain.

Return type:

int

_ConnectPODdevice(deviceNum: int, deviceParams: Params8206HR) bool

Creates a POD_8206HR object and write the setup parameters to it.

Parameters:
  • deviceNum (int) – Integer of the device’s number.

  • deviceParams (Params_8206HR) – Device’s parameters.

Returns:

True if connection was successful, false otherwise.

Return type:

bool

_GetPODdeviceParameterTable() Texttable

Builds a table containing the parameters for all POD devices.

Returns:

Texttable containing all parameters.

Return type:

Texttable

_GetParam_onePODdevice(forbiddenNames: list[str] = []) Params8206HR

Asks the user to input all the device parameters.

Parameters:

forbiddenNames (list[str]) – List of port names already used by other devices.

Returns:

Dictionary of device parameters.

Return type:

dict[str,(str|int|dict[str,int])]

_PHYSICAL_BOUND_uV: int = 2046

Class-level integer representing the max/-min physical value in uV. Used for EDF files.

_StreamThreading() tuple[dict[int, threading.Thread]]

Start streaming from each POD device and save each to a file.

Returns:

Tuple of two items, the first is for the bucket and the second is the drain. Each item is a dictionary with device number keys and started Thread items.

Return type:

tuple[dict[int,Thread]]

Setup.SetupOneDevice.Setup_8229 module

class Setup.SetupOneDevice.Setup_8229.Setup8229

Bases: SetupInterface

Setup_8229 provides the setup functions for an 8229 POD device.

_streamMode

True when the user wants to stream data from an 8229 POD device, False otherwise.

Type:

bool

static GetDeviceName() str

Returns the name of the POD device.

Returns:

Return type:

str

static GetSupportedFileExtensions() list[str]

Returns a list containing valid file extensions.

Returns:

List of string file extensions.

Return type:

list[str]

StopStream() None

Update the state flag to signal to stop streaming data.

_ConnectPODdevice(deviceNum: int, deviceParams: Params8229) bool

Creates a 8229 POD device object and write the setup parameters to it.

Parameters:
  • deviceNum (int) – Integer of the device’s number.

  • deviceParams (Params_8229) – Device parameters.

Returns:

True if connection was successful, false otherwise.

Return type:

bool

_GetPODdeviceParameterTable() Texttable

Builds a table containing the parameters for all POD devices.

Returns:

Table containing all parameters.

Return type:

Texttable

_GetParam_onePODdevice(forbiddenNames: list[str] = []) Params8229

Asks the user to input all the device parameters.

Parameters:

forbiddenNames (list[str], optional) – List of port names already used by other devices. Defaults to [].

Returns:

Device parameters.

Return type:

Params_8229

static _GetScheduleForWeek() dict[str, tuple[int]]

Asks the user to input if the motor is on/off for each hour of each day of the week.

Returns:

Dictionary with the schedule. The keys are the days of the week (Sunday, Monday, …). The values are a tuple of 24 items for each hour; the items are 1 if the motor is on or 0 if the motor is off

Return type:

dict[str, tuple[int]]

_OpenSaveFile_EDF(fname: str, devNum: int)

EDF files are not supported for 8229 POD devices. Overwrites the parent’s method, which would open an EDF file and write the header.

Parameters:
  • fname (str) – String filename. Not used.

  • devNum (int) – Integer device number. Not used.

Raises:

Exception – EDF filetype is not supported for 8229 POD devices.

_OpenSaveFile_TXT(fname: str) IOBase

Opens a text file and writes the column names. Writes the current date/time at the top of the txt file.

Parameters:

fname (str) – String filename.

Returns:

Opened file.

Return type:

IOBase

_StreamThreading() dict[int, threading.Thread]

Opens a save file, then creates a thread for each device to stream and write data from.

Returns:

Dictionary with keys as the device number and values as the started Thread.

Return type:

dict[int,Thread]

_StreamUntilStop(pod: Pod8229, file: IOBase) None

Saves a log of all packets recieved from the 8229 POD device until the user decides to stop streaming.

Parameters:
  • pod (POD_8229) – POD device to read from.

  • file (IOBase) – Opened text file to save data to.

Setup.SetupOneDevice.Setup_8274D module

class Setup.SetupOneDevice.Setup_8274D.Setup8274D

Bases: SetupInterface

Setup_8480SC provides the setup functions for an 8480-SC POD device.

_streamMode

Set to True when the user wants to start streaming data from an 8480 POD device, False otherwise.

Type:

bool

static GetDeviceName() str

Returns the name of the POD device.

Returns:

String of _NAME.

Return type:

str

static GetSupportedFileExtensions() list[str]

Returns a list containing valid file extensions.

Returns:

List of string file extensions.

Return type:

list[str]

static NameDecode(name: str) str

Converts decimal valued name into more understandable ascii values.

Parameters:

name (str) – This represents the name of the device(which is in decimal value.)

Returns:

returns name of the device in ascii values.

Return type:

str

StopStream() None

Write a command to stop streaming data to all POD devices.

_ConnectPODdevice(deviceNum: int, deviceParams: Params8274D) bool

Creates a POD_8274D object and write the setup parameters to it.

Parameters:
  • deviceNum (int) – Integer of the device’s number.

  • deviceParams (Params_8274D) – Device parameters.

Returns:

True if connection was successful, false otherwise.

Return type:

bool

_GetPODdeviceParameterTable() Texttable

Builds a table containing the parameters for all POD devices.

Returns:

Texttable containing all parameters.

Return type:

Texttable

_GetParam_onePODdevice(forbiddenNames: list[str] = []) Params8274D

Asks the user to input all the device parameters.

Parameters:

forbiddenNames (list[str]) – List of port names already used by other devices.

Returns:

Device parameters.

Return type:

Params_8480SC

_OpenSaveFile_EDF(fname: str, devNum: int)

EDF files are not supported for 8480 POD devices. Overwrites the parent’s method, which would open an EDF file and write the header.

Parameters:
  • fname (str) – String filename. Not used.

  • devNum (int) – Integer device number. Not used.

Raises:

Exception – EDF filetype is not supported for 8480 POD devices.

_OpenSaveFile_TXT(fname: str) IOBase

Opens a text file and writes the column names. Writes the current date/time at the top of the txt file.

Parameters:

fname (str) – String filename.

Returns:

Opened file.

Return type:

IOBase

_StreamThreading() tuple[dict[int, threading.Thread]]

Start streaming from each POD device and save each to a file.

Returns:

Tuple of two items, the first is for the bucket and the second is the drain. Each item is a dictionary with device number keys and started Thread items.

Return type:

tuple[dict[int,Thread]]

Setup.SetupOneDevice.Setup_8401HR module

class Setup.SetupOneDevice.Setup_8401HR.Setup8401HR

Bases: SetupInterface

Setup_8401HR provides the setup functions for an 8206-HR POD device. REQUIRES FIRMWARE 1.0.2 OR HIGHER.

_bucketAccess

Dictionary with device number keys and Bucket values. This is updated in _StreamThreading() and cleared in StopStream().

Type:

dict[int,Bucket]

static GetDeviceName() str

returns the name of the 8401-HR POD device.

Returns:

8401-HR.

Return type:

str

StopStream() None

Write a command to stop streaming data to all POD devices.

static _CodeDCmode(dcMode: str) int

gets the integer payload to use for ‘SET DC MODE’ commands given the mode.

Parameters:

dcMode (str) – DC mode VBIAS or AGND.

Raises:

Exception – DC Mode value is not supported.

Returns:

Integer code representing the DC mode.

Return type:

int

static _CodeHighpass(highpass: float) int

Gets the integer payload to use for ‘SET HIGHPASS’ given a highpass value.

Parameters:

highpass (float) – Highpass value in Hz.

Raises:

Exception – High-pass value is not supported.

Returns:

Integer code representing the highpass value.

Return type:

int

_ConnectPODdevice(deviceNum: int, deviceParams: Params8401HR) bool

Creates a POD_8206HR object and write the setup parameters to it.

Parameters:
  • deviceNum (int) – Integer of the device’s number.

  • deviceParams (Params_8401HR) – Device parameters.

Returns:

True if connection was successful, false otherwise.

Return type:

bool

_GetPODdeviceParameterTable() Texttable

Builds a table containing the parameters for all POD devices.

Returns:

Texttable containing all parameters.

Return type:

Texttable

_GetParam_onePODdevice(forbiddenNames: list[str] = []) Params8401HR

Asks the user to input all the device parameters.

Parameters:

forbiddenNames (list[str]) – List of port names already used by other devices.

Returns:

Device parameters.

Return type:

Params_8401HR

_GetPreampDeviceName() str

Asks the user to select a mouse/rat preamplifier.

Returns:

String of the chosen preamplifier.

Return type:

str

_NiceABCDtableText(abcdValues: list[int | str | None], channelMap: dict[str, str]) str

Builds a string that formats the channel values to be input into the parameter table.

Parameters:
  • abcdValueDict (dict[str,int | str | None]) – Dictionary with ABCD keys.

  • channelMap (dict[str,str]) – Maps the ABCD channels to the sensor’s channel name.

Returns:

String with “channel name: value newline…” for each channel.

Return type:

str

_PHYSICAL_BOUND_uV: int = 2046

Class-level integer representing the max/-min physical value in uV. Used for EDF files.

static _SetBias(channelName: str) float

Asks the user for the bias voltage in V (+/-2.048V).

Parameters:

channelName (str) – Name of the channel.

Returns:

A float for thebias voltage in V.

Return type:

float

static _SetDCMode(channelName: str) str

Asks the user for the DC mode (VBIAS or AGND).

Parameters:

channelName (str) – Name of the channel.

Returns:

String for the DC mode.

Return type:

str

_SetForMappedChannels(message: str, channelMap: dict[str, str], func: function) tuple[int | None]

Asks the user to input values for all channels (excluding no-connects).

Parameters:
  • message (str) – Message to ask the user.

  • channelMap (dict[str,str]) – Maps the ABCD channels to the sensor’s channel name.

  • func (function) – a function that asks the user for an input. takes one string parameter and returns one value.

Returns:

Tuple with user inputs for values for the ABCD channels

Return type:

tuple[int|None]

static _SetHighpass(channelName: str) float | None

Asks the user for the high-pass in Hz (0.5,1,10Hz, or DC).

Parameters:

channelName (str) – Name of the channel.

Returns:

A float for the high-pass frequency in Hz, or None if DC.

Return type:

float|None

static _SetLowpass(channelName: str) int | None

Asks the user for the low-pass in Hz (21-15000Hz).

Parameters:

channelName (str) – Name of the channel.

Returns:

An integer for the low-pass frequency in Hz.

Return type:

int|None

static _SetPreampGain(channelName: str) int | None

Asks the user for the preamplifier gain.

Parameters:

channelName (str) – Name of the channel.

Returns:

An integer for the gain, or None if no gain.

Return type:

int|None

static _SetSSGain(channelName: str) int

Asks the user for the second stage gain.

Parameters:

channelName (str) – Name of the channel.

Returns:

An integer for the gain.

Return type:

int

_StreamThreading() tuple[dict[int, threading.Thread]]

Start streaming from each POD device and save each to a file.

Returns:

Tuple of two items, the first is for the bucket and the second is the drain. Each item is a dictionary with device number keys and started Thread items.

Return type:

tuple[dict[int,Thread]]

Setup.SetupOneDevice.Setup_8480SC module

class Setup.SetupOneDevice.Setup_8480SC.Setup8480SC

Bases: SetupInterface

Setup_8480SC provides the setup functions for an 8480-SC POD device.

_streamMode

Set to True when the user wants to start streaming data from an 8480 POD device, False otherwise.

Type:

bool

static GetDeviceName() str

Returns the name of the POD device.

Returns:

String of _NAME.

Return type:

str

static GetSupportedFileExtensions() list[str]

Returns a list containing valid file extensions.

Returns:

List of string file extensions.

Return type:

list[str]

StopStream() None

Update the state flag to signal to stop streaming data.

static _ChoosePeriod() tuple[int]

Asks the user an input value for Stimulus Period, which is then seperated into Period_ms and Period_us. Seperation is required because the ‘SET STIMULUS’ requires 7 items in payload, and the second and third items is the Period_ms and Period_us.

Returns:

Formatted period into millisecs and microsecs.

Return type:

tuple[int]

static _ChooseRepeat() int

Asks the user to input a value for the number of stimulus pulses to perform.

Returns:

representing repeat count for command ‘SET STIMULUS’.

Return type:

int

static _ChooseStimulusConfig() int

Asks the user to input values for Config format of Stimulus

Returns:

Formatted Stimulus Config value.

Return type:

(int)

static _ChooseSyncConfig() int

Asks the user to input values for Sync Config bits.

Returns:

Value calculated from the input bits, this value would be given as payload.

Return type:

int

static _ChooseWidth() tuple[int]

Asks the user an input value for Stimulus width, which is then seperated into width_ms and width_us. Seperation is required because the ‘SET STIMULUS’ requires 7 items in payload, and the fourth and fifth items is the width_ms and width_us.

Returns:

Formatted given width into millisecs and microsecs

Return type:

tuple[int]

_ConnectPODdevice(deviceNum: int, deviceParams: Params8480SC) bool

Creates a POD_8206HR object and write the setup parameters to it.

Parameters:
  • deviceNum (int) – Integer of the device’s number.

  • deviceParams (Params_8480SC) – Device parameters.

Returns:

True if connection was successful, false otherwise.

Return type:

bool

_GetPODdeviceParameterTable() Texttable

Builds a table containing the parameters for all POD devices.

Returns:

Texttable containing all parameters.

Return type:

Texttable

_GetParam_onePODdevice(forbiddenNames: list[str] = []) Params8480SC

Asks the user to input all the device parameters.

Parameters:

forbiddenNames (list[str]) – List of port names already used by other devices.

Returns:

Device parameters.

Return type:

Params_8480SC

_OpenSaveFile_EDF(fname: str, devNum: int)

EDF files are not supported for 8480 POD devices. Overwrites the parent’s method, which would open an EDF file and write the header.

Parameters:
  • fname (str) – String filename. Not used.

  • devNum (int) – Integer device number. Not used.

Raises:

Exception – EDF filetype is not supported for 8480 POD devices.

_OpenSaveFile_TXT(fname: str) IOBase

Opens a text file and writes the column names. Writes the current date/time at the top of the txt file.

Parameters:

fname (str) – String filename.

Returns:

Opened file.

Return type:

IOBase

_StreamThreading() dict[int, threading.Thread]

Opens a save file, then creates a thread for each device to stream and write data from.

Returns:

Dictionary with keys as the device number and values as the started Thread.

Return type:

dict[int,Thread]

_StreamUntilStop(pod: Pod8480SC, file: IOBase) None

Saves a log of all packets recieved from the 8480 POD device until the user decides to stop streaming.

Parameters:
  • pod (POD_8480) – POD device to read from.

  • file (IOBase) – Opened text file to save data to.

static _TtlSetup() int

Asks the user to input values for Config format values of TTL Setup.

Returns:

Formatted TTL Setup config value.

Setup.SetupOneDevice.Setup_PodInterface module

class Setup.SetupOneDevice.Setup_PodInterface.SetupInterface

Bases: object

Setup_Interface provides the basic interface of required methods for subclasses to implement. SetupPodDevices.py is designed to handle any of these children.

_podDevices

Instance-level dictionary of pod device objects. MUST have keys as device number.

Type:

dict[int,POD_Basics]

_podParametersDict

Instance-level dictionary of device information. MUST have keys as device number.

Type:

dict[int,Params_Interface]

_saveFileName

Instance-level string filename: <path>/file.ext. The device name and number will be appended to the filename.

Type:

str

AddPODdevice() None

Asks the user for the parameters for the new device. A new device number is generated.

AreDeviceParamsValid(paramDict: None | dict[int, Morelia.Parameters.ParamsBasic.Params])

Checks if the parameters dictionary is valid.

Parameters:

paramDict (None | dict[int,Params_Interface]) – Dictionary of parameters for all POD devices.

Raises:
  • Exception – Parameters must be contained in a dictionary.

  • Exception – Device keys must be integer type.

  • Exception – Device parameters must be dictionary type.

  • Exception – Device parameters dictionary is empty.

ConnectAllPODdevices() bool

Connects all setup POD devices.

Returns:

True if all devices are successfully connected, false otherwise.

Return type:

bool

DisplayPODdeviceParameters() None

Display all the pod device parameters in a table.

static GetDeviceName() str

returns the name of the POD device.

Returns:

GENERIC.

Return type:

str

GetPODparametersInit() str

Gets a dictionary whose keys are the device number and the value is the device parameters dict. :returns: String representation of a dictionary of POD device parameters. The keys are the device number. :rtype: str

GetSaveFileName() str

Gets the path and filename where streaming data is saved to.

Returns:

String of the save file name and path (_saveFileName).

Return type:

str

static GetSupportedFileExtensions() list[str]

Returns a list containing valid file extensions.

Returns:

List of string file extensions.

Return type:

list[str]

PrintSaveFile() None

Prints the file path and name that data is saved to. Note that the device name and number will be appended to the end of the filename.

SetupFileName(fileName: str | None = None) None

Gets the file path and name to save streaming data to. Note that the device name and number will be appended to the end of the filename.

Parameters:

fileName (str | None, optional) – Name and path of the file, if known. Defaults to None.

SetupPODparameters(podParametersDict: dict[int, Morelia.Parameters.ParamsBasic.Params] | None = None) None

Sets the parameters for the POD devices.

Parameters:

podParametersDict (dict[int,Params_Interface] | None, optional) – dictionary of the device parameters for all devices. Defaults to None.

StopStream() None

Write a command to stop streaming data to all POD devices.

Stream() tuple[dict[int, threading.Thread]] | dict[int, threading.Thread]

Tests that all devices are connected then starts streaming data.

Raises:

Exception – Test connection failed.

Returns:

Dictionary with keys as the device number and values as the started Thread. If a tuple, the first item is the Bucket and second is the BucketDrain Threads.

Return type:

tuple[dict[int,Thread]] | dict[int,Thread]

ValidateParams() None

Displays a table of the parameters of all devices, then asks the user if everything is correct. The user can then edit the parameters of a device.

_BuildFileName(devNum: int) str

Appends the device name and number to the end of the file name.

Parameters:

devNum (int) – Integer of the device number.

Returns:

String file name.

Return type:

str

static _ChoosePort(forbidden: list[str] = []) str

Systems checks user’s Operating System, and chooses ports accordingly.

Parameters:

forbidden (list[str], optional) – List of port names that are already used. Defaults to [].

Returns:

String name of the port.

Return type:

str

_ConnectPODdevice(deviceNum: int, deviceParams: Params) bool

Creates a POD device object and write the setup parameters to it.

Parameters:
  • deviceNum (int) – Integer of the device’s number.

  • deviceParams (Params_Interface) – Device parameters.

Returns:

True if connection was successful, false otherwise.

Return type:

bool

_DisconnectAllPODdevices() None

Disconnects all POD devices by deleted all POD obejcts.

_EditParams() None

Asks the user which device to edit, and then asks them to re-input the device parameters.

_GetForbiddenNames(exclude: str | None = None) list[str]

Generates a list of port names used by the active pod devices. There is an option to exclude an additional name from the list.

Parameters:

exclude (str | None, optional) – String port name to exclude from the returned list. Defaults to None.

Returns:

List of string names of ports in use.

Return type:

list[str]

_GetPODdeviceParameterTable() Texttable

Builds a table containing the parameters for all POD devices.

Returns:

Table containing all parameters.

Return type:

Texttable

_GetParam_allPODdevices() dict[int, Morelia.Parameters.ParamsBasic.Params]

First gets the number of POD devices, then asks the user for the information for each device.

Returns:

Dictionary with device numbers for keys and parameters for values.

Return type:

dict[int,Params_Interface]

_GetParam_onePODdevice(forbiddenNames: list[str] = []) Params

Asks the user to input all the device parameters.

Parameters:

forbiddenNames (list[str]) – List of port names already used by other devices. Defaults to [].

Returns:

Device parameters.

Return type:

Params_Interface

static _GetTimeHeader_forTXT() str

Builds a string containing the current date and time to be written to the text file header.

Returns:

String containing the date and time. Each line begins with ‘#’ and ends with a newline.

Return type:

str

_OpenSaveFile(devNum: int) IOBase | EdfWriter

Opens a save file for a given device.

Parameters:

devNum (int) – Integer of the device number.

Returns:

Opened file. IOBase for a text file, or EdfWriter for EDF file.

Return type:

IOBase | EdfWriter

_OpenSaveFile_EDF(fname: str, devNum: int) EdfWriter

Opens EDF file and write header.

Parameters:
  • fname (str) – String filename.

  • devNum (int) – Integer device number.

Returns:

Opened file.

Return type:

EdfWriter

_OpenSaveFile_TXT(fname: str) IOBase

Opens a text file and writes the column names. Writes the current date/time at the top of the txt file.

Parameters:

fname (str) – String filename.

Returns:

Opened file.

Return type:

IOBase

static _PrintDeviceNumber(num: int) None

Prints a title with the device number.

Parameters:

num (int) – Integer of the device number.

_RemoveDevice() None

Asks the user for a device number to remove, then deletes that device. This will only remove a device if there are more than one options.

_SelectDeviceFromDict(action: str) int

Asks the user to select a valid device number. The input must be an integer number of an existing device.

Parameters:

action (str) – Description of the action to be performed on the device.

Returns:

Integer for the device number.

Return type:

int

static _SetNumberOfDevices(name: str) int

Asks the user for how many devices they want to setup.

Parameters:

name (str) – Name of the POD device type.

Returns:

Integer number of POD devices desired by the user.

Return type:

int

_StreamThreading() tuple[dict[int, threading.Thread]] | dict[int, threading.Thread]

Start streaming from each POD device and save each to a file.

Returns:

Dictionary with keys as the device number and values as the started Thread. If a tuple, the first item is the Bucket and second is the BucketDrain Threads.

Return type:

tuple[dict[int,Thread]] | dict[int,Thread]

static _TestDeviceConnection(pod: Pod) bool

Tests if a POD device can be read from or written. Sends a PING command.

Parameters:

pod (POD_Basics) – POD device to read to and write from.

Returns:

True for successful connection, false otherwise.

Return type:

bool

_TestDeviceConnection_All() bool

Tests the connection of all setup POD devices.

Returns:

True when all devices are successfully connected, false otherwise

Return type:

bool

static _uV(voltage: float | int) float

Converts volts to microVolts, rounded to 6 decimal places.

Parameters:

voltage (float | int) – number of volts.

Returns:

voltage in of uV.

Return type:

float

Module contents