initial commit
This commit is contained in:
7
mne/io/bti/__init__.py
Normal file
7
mne/io/bti/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""BTi module for conversion to FIF."""
|
||||
|
||||
# Authors: The MNE-Python contributors.
|
||||
# License: BSD-3-Clause
|
||||
# Copyright the MNE-Python contributors.
|
||||
|
||||
from .bti import read_raw_bti
|
||||
1414
mne/io/bti/bti.py
Normal file
1414
mne/io/bti/bti.py
Normal file
File diff suppressed because it is too large
Load Diff
99
mne/io/bti/constants.py
Normal file
99
mne/io/bti/constants.py
Normal file
@@ -0,0 +1,99 @@
|
||||
# Authors: The MNE-Python contributors.
|
||||
# License: BSD-3-Clause
|
||||
# Copyright the MNE-Python contributors.
|
||||
|
||||
from ...utils import BunchConst
|
||||
|
||||
BTI = BunchConst()
|
||||
|
||||
BTI.ELEC_STATE_NOT_COLLECTED = 0
|
||||
BTI.ELEC_STATE_COLLECTED = 1
|
||||
BTI.ELEC_STATE_SKIPPED = 2
|
||||
BTI.ELEC_STATE_NOT_APPLICABLE = 3
|
||||
#
|
||||
## Byte offesets and data sizes for different files
|
||||
#
|
||||
BTI.FILE_MASK = 2147483647
|
||||
BTI.FILE_CURPOS = 8
|
||||
BTI.FILE_END = -8
|
||||
|
||||
BTI.FILE_HS_VERSION = 0
|
||||
BTI.FILE_HS_TIMESTAMP = 4
|
||||
BTI.FILE_HS_CHECKSUM = 8
|
||||
BTI.FILE_HS_N_DIGPOINTS = 12
|
||||
BTI.FILE_HS_N_INDEXPOINTS = 16
|
||||
|
||||
BTI.FILE_PDF_H_ENTER = 1
|
||||
BTI.FILE_PDF_H_FTYPE = 5
|
||||
BTI.FILE_PDF_H_XLABEL = 16
|
||||
BTI.FILE_PDF_H_NEXT = 2
|
||||
BTI.FILE_PDF_H_EXIT = 20
|
||||
|
||||
BTI.FILE_PDF_EPOCH_EXIT = 28
|
||||
|
||||
BTI.FILE_PDF_CH_NEXT = 6
|
||||
BTI.FILE_PDF_CH_LABELSIZE = 16
|
||||
BTI.FILE_PDF_CH_YLABEL = 16
|
||||
BTI.FILE_PDF_CH_OFF_FLAG = 16
|
||||
BTI.FILE_PDF_CH_EXIT = 12
|
||||
|
||||
BTI.FILE_PDF_EVENT_NAME = 16
|
||||
BTI.FILE_PDF_EVENT_EXIT = 32
|
||||
|
||||
BTI.FILE_PDF_PROCESS_BLOCKTYPE = 20
|
||||
BTI.FILE_PDF_PROCESS_USER = 32
|
||||
BTI.FILE_PDF_PROCESS_FNAME = 256
|
||||
BTI.FILE_PDF_PROCESS_EXIT = 32
|
||||
|
||||
BTI.FILE_PDF_ASSOC_NEXT = 32
|
||||
|
||||
BTI.FILE_PDFED_NAME = 17
|
||||
BTI.FILE_PDFED_NEXT = 9
|
||||
BTI.FILE_PDFED_EXIT = 8
|
||||
|
||||
#
|
||||
## General data constants
|
||||
#
|
||||
BTI.DATA_N_IDX_POINTS = 5
|
||||
BTI.DATA_ROT_N_ROW = 3
|
||||
BTI.DATA_ROT_N_COL = 3
|
||||
BTI.DATA_XFM_N_COL = 4
|
||||
BTI.DATA_XFM_N_ROW = 4
|
||||
BTI.FIFF_LOGNO = 111
|
||||
#
|
||||
## Channel Types
|
||||
#
|
||||
BTI.CHTYPE_MEG = 1
|
||||
BTI.CHTYPE_EEG = 2
|
||||
BTI.CHTYPE_REFERENCE = 3
|
||||
BTI.CHTYPE_EXTERNAL = 4
|
||||
BTI.CHTYPE_TRIGGER = 5
|
||||
BTI.CHTYPE_UTILITY = 6
|
||||
BTI.CHTYPE_DERIVED = 7
|
||||
BTI.CHTYPE_SHORTED = 8
|
||||
#
|
||||
## Processes
|
||||
#
|
||||
BTI.PROC_DEFAULTS = "BTi_defaults"
|
||||
BTI.PROC_FILTER = "b_filt_hp,b_filt_lp,b_filt_notch"
|
||||
BTI.PROC_BPFILTER = "b_filt_b_pass,b_filt_b_reject"
|
||||
#
|
||||
## User blocks
|
||||
#
|
||||
BTI.UB_B_MAG_INFO = "B_Mag_Info"
|
||||
BTI.UB_B_COH_POINTS = "B_COH_Points"
|
||||
BTI.UB_B_CCP_XFM_BLOCK = "b_ccp_xfm_block"
|
||||
BTI.UB_B_EEG_LOCS = "b_eeg_elec_locs"
|
||||
BTI.UB_B_WHC_CHAN_MAP_VER = "B_WHChanMapVer"
|
||||
BTI.UB_B_WHC_CHAN_MAP = "B_WHChanMap"
|
||||
BTI.UB_B_WHS_SUBSYS_VER = "B_WHSubsysVer" # B_WHSubsysVer
|
||||
BTI.UB_B_WHS_SUBSYS = "B_WHSubsys"
|
||||
BTI.UB_B_CH_LABELS = "B_ch_labels"
|
||||
BTI.UB_B_CALIBRATION = "B_Calibration"
|
||||
BTI.UB_B_SYS_CONFIG_TIME = "B_SysConfigTime"
|
||||
BTI.UB_B_DELTA_ENABLED = "B_DELTA_ENABLED"
|
||||
BTI.UB_B_E_TABLE_USED = "B_E_table_used"
|
||||
BTI.UB_B_E_TABLE = "B_E_TABLE"
|
||||
BTI.UB_B_WEIGHTS_USED = "B_weights_used"
|
||||
BTI.UB_B_TRIG_MASK = "B_trig_mask"
|
||||
BTI.UB_B_WEIGHT_TABLE = "BWT_"
|
||||
98
mne/io/bti/read.py
Normal file
98
mne/io/bti/read.py
Normal file
@@ -0,0 +1,98 @@
|
||||
# Authors: The MNE-Python contributors.
|
||||
# License: BSD-3-Clause
|
||||
# Copyright the MNE-Python contributors.
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ..._fiff.utils import read_str
|
||||
|
||||
|
||||
def _unpack_matrix(fid, rows, cols, dtype, out_dtype):
|
||||
"""Unpack matrix."""
|
||||
dtype = np.dtype(dtype)
|
||||
|
||||
string = fid.read(int(dtype.itemsize * rows * cols))
|
||||
out = np.frombuffer(string, dtype=dtype).reshape(rows, cols).astype(out_dtype)
|
||||
return out
|
||||
|
||||
|
||||
def _unpack_simple(fid, dtype, out_dtype):
|
||||
"""Unpack a NumPy type."""
|
||||
dtype = np.dtype(dtype)
|
||||
string = fid.read(dtype.itemsize)
|
||||
out = np.frombuffer(string, dtype=dtype).astype(out_dtype)
|
||||
|
||||
if len(out) > 0:
|
||||
out = out[0]
|
||||
return out
|
||||
|
||||
|
||||
def read_char(fid, count=1):
|
||||
"""Read character from bti file."""
|
||||
return _unpack_simple(fid, f">S{count}", "S")
|
||||
|
||||
|
||||
def read_uint16(fid):
|
||||
"""Read unsigned 16bit integer from bti file."""
|
||||
return _unpack_simple(fid, ">u2", np.uint32)
|
||||
|
||||
|
||||
def read_int16(fid):
|
||||
"""Read 16bit integer from bti file."""
|
||||
return _unpack_simple(fid, ">i2", np.int32)
|
||||
|
||||
|
||||
def read_uint32(fid):
|
||||
"""Read unsigned 32bit integer from bti file."""
|
||||
return _unpack_simple(fid, ">u4", np.uint32)
|
||||
|
||||
|
||||
def read_int32(fid):
|
||||
"""Read 32bit integer from bti file."""
|
||||
return _unpack_simple(fid, ">i4", np.int32)
|
||||
|
||||
|
||||
def read_int64(fid):
|
||||
"""Read 64bit integer from bti file."""
|
||||
return _unpack_simple(fid, ">u8", np.int64)
|
||||
|
||||
|
||||
def read_float(fid):
|
||||
"""Read 32bit float from bti file."""
|
||||
return _unpack_simple(fid, ">f4", np.float32)
|
||||
|
||||
|
||||
def read_double(fid):
|
||||
"""Read 64bit float from bti file."""
|
||||
return _unpack_simple(fid, ">f8", np.float64)
|
||||
|
||||
|
||||
def read_int16_matrix(fid, rows, cols):
|
||||
"""Read 16bit integer matrix from bti file."""
|
||||
return _unpack_matrix(
|
||||
fid,
|
||||
rows,
|
||||
cols,
|
||||
dtype=">i2",
|
||||
out_dtype=np.int32,
|
||||
)
|
||||
|
||||
|
||||
def read_float_matrix(fid, rows, cols):
|
||||
"""Read 32bit float matrix from bti file."""
|
||||
return _unpack_matrix(fid, rows, cols, dtype=">f4", out_dtype=np.float32)
|
||||
|
||||
|
||||
def read_double_matrix(fid, rows, cols):
|
||||
"""Read 64bit float matrix from bti file."""
|
||||
return _unpack_matrix(fid, rows, cols, dtype=">f8", out_dtype=np.float64)
|
||||
|
||||
|
||||
def read_transform(fid):
|
||||
"""Read 64bit float matrix transform from bti file."""
|
||||
return read_double_matrix(fid, rows=4, cols=4)
|
||||
|
||||
|
||||
def read_dev_header(x):
|
||||
"""Create a dev header."""
|
||||
return dict(size=read_int32(x), checksum=read_int32(x), reserved=read_str(x, 32))
|
||||
Reference in New Issue
Block a user