pyNAVIS.functions

Functions

class pyNAVIS.functions.Functions[source]

Methods:

ISI(spikes_file[, verbose])

Generates an array with the inter-spike intervals of the input SpikesFile.

adapt_timestamps(spikes_file, settings)

Subtracts the smallest timestamp of the timestamps list to all of the timestamps contained in the list (in order to start from 0) It also adapts timestamps based on the tick frequency (ts_tick in the MainSettings).

check_LocalizationFile(localization_file, ...)

Checks if the spiking information contained in the LocalizationFile is correct and prints "The loaded LocalizationFile file has been checked and it's OK" if the file passes all the checks.

check_SpikesFile(spikes_file, settings)

Checks if the spiking information contained in the SpikesFile is correct and prints "The loaded SpikesFile file has been checked and it's OK" if the file passes all the checks.

extract_channels_activities(spikes_file, ...)

Extract information from a specific set of addresses from the SpikesFile.

mono_to_stereo(spikes_file, delay, settings)

Generates a stereo AEDAT SpikesFile from a mono SpikesFile with a specific delay between both.

phase_lock(spikes_file, settings[, posNeg_both])

Performs the phase lock operation over a SpikesFile.

stereo_to_mono(spikes_file, left_right, settings)

Generates a mono AEDAT SpikesFile from a stereo SpikesFile.

static ISI(spikes_file, verbose=False)[source]

Generates an array with the inter-spike intervals of the input SpikesFile.

Parameters:
  • spikes_file (SpikesFile or string) – File or path to use.

  • settings (MainSettings) – Configuration parameters for the input file.

  • verbose (boolean, optional) – Set to True if you want the execution time of the function to be printed.

Returns:

int[] – inter-spike interval array.

static adapt_timestamps(spikes_file, settings)[source]

Subtracts the smallest timestamp of the timestamps list to all of the timestamps contained in the list (in order to start from 0) It also adapts timestamps based on the tick frequency (ts_tick in the MainSettings).

Parameters:
  • spikes_file

  • settings (MainSettings) – Configuration parameters for the file to adapt.

Returns:

adapted_timestamps – Adapted timestamps list.

static check_LocalizationFile(localization_file, settings, localization_settings)[source]

Checks if the spiking information contained in the LocalizationFile is correct and prints “The loaded LocalizationFile file has been checked and it’s OK” if the file passes all the checks.

Parameters:
  • localization_file (LocalizationFile) – File to check.

  • settings (MainSettings) – Configuration parameters for the file to check.

  • localization_settings (LocalizationSettings) – Configuration parameters of the localization model for the file to check.

Returns:

None.

Raises:
  • TimestampOrderError – If the LocalizationFile contains at least one timestamp which value is less than 0.

  • TimestampOrderError – If the LocalizationFile contains at least one timestamp that is lesser than its previous one.

  • ChannelValueError – If the LocalizationFile contains at least one address less than mso_start_channel or greater than mso_end_channel that you specified in the LocalizationSettings.

  • NeuronIDValueError – If the LocalizationFile contains at least one address less than 0 or greater than the mso_num_neurons_channel you specified in LocalizationSettings

Notes

If mso_start_channel is set to 33 and mso_end_channel is set to 36, there will be four possible channel values: [33, 36]

static check_SpikesFile(spikes_file, settings)[source]

Checks if the spiking information contained in the SpikesFile is correct and prints “The loaded SpikesFile file has been checked and it’s OK” if the file passes all the checks.

Parameters:
  • spikes_file (SpikesFile) – File to check.

  • settings (MainSettings) – Configuration parameters for the file to check.

Returns:

None.

Raises:
  • TimestampOrderError – If the SpikesFile contains at least one timestamp which value is less than 0.

  • TimestampOrderError – If the SpikesFile contains at least one timestamp that is lesser than its previous one.

  • AddressValueError – If the SpikesFile contains at least one address less than 0 or greater than the num_channels that you specified in the MainSettings.

Notes

If mono_stereo is set to 1 (stereo) in the MainSettings, then addresses should be less than num_channels*2.

If on_off_both is set to 1 (both) in the MainSettings, then addresses should be less than num_channels*2.

If mono_stereo is set to 1 and on_off_both is set to 1 in the MainSettings, then addresses should be less than num_channels*2*2.

static extract_channels_activities(spikes_file, addresses, reset_addresses=True, verbose=False)[source]

Extract information from a specific set of addresses from the SpikesFile.

Parameters:
  • spikes_file (SpikesFile) – File to use.

  • addresses (int[]) – List of addresses to extract.

  • reset_addresses (boolean, optional) – If set to true, addresses IDs will start from 0. If not, they will keep their original IDs.

  • verbose (boolean, optional) – Set to True if you want the execution time of the function to be printed.

Returns:

SpikesFile – SpikesFile containing only the information from the addresses specified as input from spikes_file.

static mono_to_stereo(spikes_file, delay, settings, return_save_both=0, path=None, output_format='.aedat')[source]

Generates a stereo AEDAT SpikesFile from a mono SpikesFile with a specific delay between both.

Parameters:
  • spikes_file (SpikesFile) – Input file.

  • delay (int) – Delay (microseconds) introduced between left and right spikes. Can be either negative or positive.

  • settings (MainSettings) – Configuration parameters for the input file.

  • return_save_both (int, optional) – Set it to 0 to return the SpikesFile, to 1 to save the SpikesFile in the output path, and to 2 to do both.

  • path (string, optional) – Path where the output file will be saved. Format should not be specified. Not needed if return_save_both is set to 0.

  • output_format (string, optional) – Output format of the file. Currently supports ‘.aedat’, ‘.csv’, “.txt” and “.txt_rel”. See the Savers class for more information.

Returns:

SpikesFile – SpikesFile containing the shift. Returned only if return_save_both is either 0 or 2.

Raises:

SettingsError – If the input file is a stereo SpikesFile (settings.mono_stereo is set to 1).

Note: The timestamp of the left event is used as reference. Thus, the timestamp of the right event will be ts_right = ts_left + delay.

static phase_lock(spikes_file, settings, posNeg_both=0)[source]

Performs the phase lock operation over a SpikesFile. This can only be performed to SpikeFiles with both ON and OFF addresses. The phaselock operation puts a spike in the output only when the spike train from a specific channel changes from ON (positive part of the signal) to OFF (negative part of the signal). This heavily reduces the number of spikes at the output.

Parameters:
  • spikes_file (SpikesFile) – File used to perform the phase lock.

  • settings (MainSettings) – Configuration parameters of the input file.

  • posNeg_both (int, optional) – If set to 0, a spike is generated only when spike trains change from ON to OFF addresses. If set to 1, a spike is generated every time spike trains change from ON to OFF addresses or vice versa.

Returns:

SpikesFile – Phase-locked SpikesFile.

Raises:

SettingsError – If the on_off_both parameter is not set to 1 (both) in the MainSettings.

static stereo_to_mono(spikes_file, left_right, settings, return_save_both=0, path=None, output_format='.aedat')[source]

Generates a mono AEDAT SpikesFile from a stereo SpikesFile.

Parameters:
  • spikes_file (SpikesFile) – Input file.

  • left_right (int) – Set to 0 if you want to extract the left part of the SpikesFile, or to 1 if you want the right part.

  • settings (MainSettings) – Configuration parameters for the input file.

  • return_save_both (int, optional) – Set it to 0 to return the SpikesFile, to 1 to save the SpikesFile in the output path, and to 2 to do both.

  • path (string, optional) – Path where the output file will be saved. Format should not be specified. Not needed if return_save_both is set to 0.

  • output_format (string, optional) – Output format of the file. Currently supports ‘.aedat’, ‘.csv’, “.txt” and “.txt_rel”. See the Savers class for more information.

Returns:

SpikesFile – SpikesFile containing the shift. Returned only if return_save_both is either 0 or 2.

Raises:

AttributeError – If the input file is a mono SpikesFile (settings.mono_stereo is set to 0).