intan.io package¶
This module contains all the I/O utilities for loading, saving, and managing Intan files.
Submodules¶
- canonical_label(s, *, style='lower', allow_fuzzy=True, fuzzy_cutoff=0.88, strict=False)[source]¶
Canonicalize a raw label string to your official namespace. :rtype:
strstyle=”camel”: return CamelCase (e.g., “PinkyFlexion”)
style=”lower”: return canonical token key (e.g., “pinkyflexion”)
- Parameters:
s (str)
style (str)
allow_fuzzy (bool)
fuzzy_cutoff (float)
strict (bool)
- Return type:
str
intan.io._exceptions
Custom exception classes used throughout the intan package.
These exceptions provide clearer debugging information for: - Invalid or corrupted .rhd files - Mismatched channel definitions - Broken TCP streams from the RHX server - File size or format inconsistencies
Each exception inherits from Exception and includes a brief description.
- exception UnrecognizedFileError[source]¶
Bases:
ExceptionException returned when reading a file as an RHD header yields an invalid magic number (indicating this is not an RHD header file).
- exception UnknownChannelTypeError[source]¶
Bases:
ExceptionException returned when a channel field in RHD header does not have a recognized signal_type value. Accepted values are: 0: amplifier channel 1: aux input channel 2: supply voltage channel 3: board adc channel 4: dig in channel 5: dig out channel
- exception FileSizeError[source]¶
Bases:
ExceptionException returned when file reading fails due to the file size being invalid or the calculated file size differing from the actual file size.
- exception QStringError[source]¶
Bases:
ExceptionException returned when reading a QString fails because it is too long.
- exception ChannelNotFoundError[source]¶
Bases:
ExceptionException returned when plotting fails due to the specified channel not being found.
- exception GetSampleRateFailure[source]¶
Bases:
ExceptionException returned when the TCP socket failed to yield the sample rate as reported by the RHX software.
- exception InvalidReceivedDataSize[source]¶
Bases:
ExceptionException returned when the amount of data received on the TCP socket is not an integer multiple of the excepted data block size.
- exception InvalidMagicNumber[source]¶
Bases:
ExceptionException returned when the first 4 bytes of a data block are not the expected RHX TCP magic number (0x2ef07a08).
- print_all_channel_names(result)[source]¶
Searches through all present signal types in ‘result’ dict, and prints the names of these channels. Useful, for example, to determine names of channels that can be plotted.
- Parameters:
result (dict) – The result of a call to read_header() or header_to_result().
- print_names_in_group(signal_group)[source]¶
Searches through all channels in this group and print them.
- Parameters:
signal_group (list) – The list of channels to search through.
- find_channel_in_group(channel_name, signal_group)[source]¶
Finds a channel with this name in this group, returning whether or not it’s present and, if so, the position of this channel in signal_group.
- Parameters:
channel_name (str) – The name of the channel to search for.
signal_group (list) – The list of channels to search through.
- Returns:
Whether or not the channel was found. channel_index (int): The index of the channel in signal_group.
- Return type:
channel_found (bool)
- find_channel_in_header(channel_name, header)[source]¶
Looks through all present signal groups in header, searching for ‘channel_name’. If found, return the signal group and the index of that channel within the group.
- Parameters:
channel_name (str) – The name of the channel to search for.
header (dict) – The header dictionary containing signal groups.
- Returns:
Whether or not the channel was found. signal_group_name (str): The name of the signal group containing the channel. channel_index (int): The index of the channel in the signal group.
- Return type:
channel_found (bool)