_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q240100 | detect_format | train | def detect_format(filename):
"""Detect file format.
Parameters
----------
filename : str or Path
name of the filename or directory.
Returns
-------
class used to read the data.
"""
filename = Path(filename)
if filename.is_dir():
if list(filename.glob('*.stc')) ... | python | {
"resource": ""
} |
q240101 | Dataset.read_videos | train | def read_videos(self, begtime=None, endtime=None):
"""Return list of videos with start and end times for a period.
Parameters
----------
begtime : int or datedelta or datetime or list
start of the data to read;
if it's int, it's assumed it's s;
if it'... | python | {
"resource": ""
} |
q240102 | Dataset.read_data | train | def read_data(self, chan=None, begtime=None, endtime=None, begsam=None,
endsam=None, s_freq=None):
"""Read the data and creates a ChanTime instance
Parameters
----------
chan : list of strings
names of the channels to read
begtime : int or datedelta... | python | {
"resource": ""
} |
q240103 | _read_dat | train | def _read_dat(x):
"""read 24bit binary data and convert them to numpy.
Parameters
----------
x : bytes
bytes (length should be divisible by 3)
Returns
-------
numpy vector
vector with the signed 24bit values
Notes
-----
It's pretty slow but it's pretty a PITA t... | python | {
"resource": ""
} |
q240104 | _read_chan_name | train | def _read_chan_name(orig):
"""Read channel labels, which can be across xml files.
Parameters
----------
orig : dict
contains the converted xml information
Returns
-------
list of str
list of channel names
ndarray
vector to indicate to which signal a channel belo... | python | {
"resource": ""
} |
q240105 | write_wonambi | train | def write_wonambi(data, filename, subj_id='', dtype='float64'):
"""Write file in simple Wonambi format.
Parameters
----------
data : instance of ChanTime
data with only one trial
filename : path to file
file to export to (the extensions .won and .dat will be added)
subj_id : str... | python | {
"resource": ""
} |
q240106 | _read_geometry | train | def _read_geometry(surf_file):
"""Read a triangular format Freesurfer surface mesh.
Parameters
----------
surf_file : str
path to surface file
Returns
-------
coords : numpy.ndarray
nvtx x 3 array of vertex (x, y, z) coordinates
faces : numpy.ndarray
nfaces x 3 ... | python | {
"resource": ""
} |
q240107 | import_freesurfer_LUT | train | def import_freesurfer_LUT(fs_lut=None):
"""Import Look-up Table with colors and labels for anatomical regions.
It's necessary that Freesurfer is installed and that the environmental
variable 'FREESURFER_HOME' is present.
Parameters
----------
fs_lut : str or Path
path to file called Fr... | python | {
"resource": ""
} |
q240108 | Freesurfer.find_brain_region | train | def find_brain_region(self, abs_pos, parc_type='aparc', max_approx=None,
exclude_regions=None):
"""Find the name of the brain region in which an electrode is located.
Parameters
----------
abs_pos : numpy.ndarray
3x0 vector with the position of inte... | python | {
"resource": ""
} |
q240109 | Freesurfer.read_seg | train | def read_seg(self, parc_type='aparc'):
"""Read the MRI segmentation.
Parameters
----------
parc_type : str
'aparc' or 'aparc.a2009s'
Returns
-------
numpy.ndarray
3d matrix with values
numpy.ndarray
4x4 affine matrix
... | python | {
"resource": ""
} |
q240110 | concatenate | train | def concatenate(data, axis):
"""Concatenate multiple trials into one trials, according to any dimension.
Parameters
----------
data : instance of DataTime, DataFreq, or DataTimeFreq
axis : str
axis that you want to concatenate (it can be 'trial')
Returns
-------
instace of sam... | python | {
"resource": ""
} |
q240111 | LyonRRI.return_rri | train | def return_rri(self, begsam, endsam):
"""Return raw, irregularly-timed RRI."""
interval = endsam - begsam
dat = empty(interval)
k = 0
with open(self.filename, 'rt') as f:
[next(f) for x in range(12)]
for j, datum in enumerate(f):
... | python | {
"resource": ""
} |
q240112 | Labels.update | train | def update(self, checked=False, labels=None, custom_labels=None):
"""Use this function when we make changes to the list of labels or when
we load a new dataset.
Parameters
----------
checked : bool
argument from clicked.connect
labels : list of str
... | python | {
"resource": ""
} |
q240113 | peaks | train | def peaks(data, method='max', axis='time', limits=None):
"""Return the values of an index where the data is at max or min
Parameters
----------
method : str, optional
'max' or 'min'
axis : str, optional
the axis where you want to detect the peaks
limits : tuple of two values, op... | python | {
"resource": ""
} |
q240114 | export_freq | train | def export_freq(xfreq, filename, desc=None):
"""Write frequency analysis data to CSV.
Parameters
----------
xfreq : list of dict
spectral data, one dict per segment, where 'data' is ChanFreq
filename : str
output filename
desc : dict of ndarray
descriptives
'"""
... | python | {
"resource": ""
} |
q240115 | export_freq_band | train | def export_freq_band(xfreq, bands, filename):
"""Write frequency analysis data to CSV by pre-defined band."""
heading_row_1 = ['Segment index',
'Start time',
'End time',
'Duration',
'Stitches',
'Stage',
... | python | {
"resource": ""
} |
q240116 | create_empty_annotations | train | def create_empty_annotations(xml_file, dataset):
"""Create an empty annotation file.
Notes
-----
Dates are made time-zone unaware.
"""
xml_file = Path(xml_file)
root = Element('annotations')
root.set('version', VERSION)
info = SubElement(root, 'dataset')
x = SubElement(info, 'f... | python | {
"resource": ""
} |
q240117 | create_annotation | train | def create_annotation(xml_file, from_fasst):
"""Create annotations by importing from FASST sleep scoring file.
Parameters
----------
xml_file : path to xml file
annotation file that will be created
from_fasst : path to FASST file
.mat file containing the scores
Returns
----... | python | {
"resource": ""
} |
q240118 | update_annotation_version | train | def update_annotation_version(xml_file):
"""Update the fields that have changed over different versions.
Parameters
----------
xml_file : path to file
xml file with the sleep scoring
Notes
-----
new in version 4: use 'marker_name' instead of simply 'name' etc
new in version 5:... | python | {
"resource": ""
} |
q240119 | Annotations.load | train | def load(self):
"""Load xml from file."""
lg.info('Loading ' + str(self.xml_file))
update_annotation_version(self.xml_file)
xml = parse(self.xml_file)
return xml.getroot() | python | {
"resource": ""
} |
q240120 | Annotations.save | train | def save(self):
"""Save xml to file."""
if self.rater is not None:
self.rater.set('modified', datetime.now().isoformat())
xml = parseString(tostring(self.root))
with open(self.xml_file, 'w') as f:
f.write(xml.toxml()) | python | {
"resource": ""
} |
q240121 | Annotations.add_bookmark | train | def add_bookmark(self, name, time, chan=''):
"""Add a new bookmark
Parameters
----------
name : str
name of the bookmark
time : (float, float)
float with start and end time in s
Raises
------
IndexError
When there is n... | python | {
"resource": ""
} |
q240122 | Annotations.remove_bookmark | train | def remove_bookmark(self, name=None, time=None, chan=None):
"""if you call it without arguments, it removes ALL the bookmarks."""
bookmarks = self.rater.find('bookmarks')
for m in bookmarks:
bookmark_name = m.find('bookmark_name').text
bookmark_start = float(m.find('boo... | python | {
"resource": ""
} |
q240123 | Annotations.remove_event_type | train | def remove_event_type(self, name):
"""Remove event type based on name."""
if name not in self.event_types:
lg.info('Event type ' + name + ' was not found.')
events = self.rater.find('events')
# list is necessary so that it does not remove in place
for e in list(eve... | python | {
"resource": ""
} |
q240124 | Annotations.remove_event | train | def remove_event(self, name=None, time=None, chan=None):
"""get events inside window."""
events = self.rater.find('events')
if name is not None:
pattern = "event_type[@type='" + name + "']"
else:
pattern = "event_type"
if chan is not None:
if ... | python | {
"resource": ""
} |
q240125 | Annotations.epochs | train | def epochs(self):
"""Get epochs as generator
Returns
-------
list of dict
each epoch is defined by start_time and end_time (in s in reference
to the start of the recordings) and a string of the sleep stage,
and a string of the signal quality.
... | python | {
"resource": ""
} |
q240126 | Annotations.get_stage_for_epoch | train | def get_stage_for_epoch(self, epoch_start, window_length=None,
attr='stage'):
"""Return stage for one specific epoch.
Parameters
----------
id_epoch : str
index of the epoch
attr : str, optional
'stage' or 'quality'
Re... | python | {
"resource": ""
} |
q240127 | Annotations.set_stage_for_epoch | train | def set_stage_for_epoch(self, epoch_start, name, attr='stage', save=True):
"""Change the stage for one specific epoch.
Parameters
----------
epoch_start : int
start time of the epoch, in seconds
name : str
description of the stage or qualifier.
at... | python | {
"resource": ""
} |
q240128 | Annotations.set_cycle_mrkr | train | def set_cycle_mrkr(self, epoch_start, end=False):
"""Mark epoch start as cycle start or end.
Parameters
----------
epoch_start: int
start time of the epoch, in seconds
end : bool
If True, marked as cycle end; otherwise, marks cycle start
"""
... | python | {
"resource": ""
} |
q240129 | Annotations.remove_cycle_mrkr | train | def remove_cycle_mrkr(self, epoch_start):
"""Remove cycle marker at epoch_start.
Parameters
----------
epoch_start: int
start time of epoch, in seconds
"""
if self.rater is None:
raise IndexError('You need to have at least one rater')
cycl... | python | {
"resource": ""
} |
q240130 | Annotations.clear_cycles | train | def clear_cycles(self):
"""Remove all cycle markers in current rater."""
if self.rater is None:
raise IndexError('You need to have at least one rater')
cycles = self.rater.find('cycles')
for cyc in list(cycles):
cycles.remove(cyc)
self.save() | python | {
"resource": ""
} |
q240131 | Annotations.get_cycles | train | def get_cycles(self):
"""Return the cycle start and end times.
Returns
-------
list of tuple of float
start and end times for each cycle, in seconds from recording start
and the cycle index starting at 1
"""
cycles = self.rater.find('cycles')
... | python | {
"resource": ""
} |
q240132 | Annotations.switch | train | def switch(self, time=None):
"""Obtain switch parameter, ie number of times the stage shifts."""
stag_to_int = {'NREM1': 1, 'NREM2': 2, 'NREM3': 3, 'REM': 5, 'Wake': 0}
hypno = [stag_to_int[x['stage']] for x in self.get_epochs(time=time) \
if x['stage'] in stag_to_int.keys()]
... | python | {
"resource": ""
} |
q240133 | Annotations.slp_frag | train | def slp_frag(self, time=None):
"""Obtain sleep fragmentation parameter, ie number of stage shifts to
a lighter stage."""
epochs = self.get_epochs(time=time)
stage_int = {'Wake': 0, 'NREM1': 1, 'NREM2': 2, 'NREM3': 3, 'REM': 2}
hypno_str = [x['stage'] for x in epochs \
... | python | {
"resource": ""
} |
q240134 | Annotations.export | train | def export(self, file_to_export, xformat='csv'):
"""Export epochwise annotations to csv file.
Parameters
----------
file_to_export : path to file
file to write to
"""
if 'csv' == xformat:
with open(file_to_export, 'w', newline='') as f:
... | python | {
"resource": ""
} |
q240135 | Info.create | train | def create(self):
"""Create the widget layout with all the information."""
b0 = QGroupBox('Dataset')
form = QFormLayout()
b0.setLayout(form)
open_rec = QPushButton('Open Dataset...')
open_rec.clicked.connect(self.open_dataset)
open_rec.setToolTip('Click here to o... | python | {
"resource": ""
} |
q240136 | Info.open_dataset | train | def open_dataset(self, recent=None, debug_filename=None, bids=False):
"""Open a new dataset.
Parameters
----------
recent : path to file
one of the recent datasets to read
"""
if recent:
filename = recent
elif debug_filename is not None:
... | python | {
"resource": ""
} |
q240137 | Info.display_dataset | train | def display_dataset(self):
"""Update the widget with information about the dataset."""
header = self.dataset.header
self.parent.setWindowTitle(basename(self.filename))
short_filename = short_strings(basename(self.filename))
self.idx_filename.setText(short_filename)
self.... | python | {
"resource": ""
} |
q240138 | Info.display_view | train | def display_view(self):
"""Update information about the size of the traces."""
self.idx_start.setText(str(self.parent.value('window_start')))
self.idx_length.setText(str(self.parent.value('window_length')))
self.idx_scaling.setText(str(self.parent.value('y_scale')))
self.idx_dist... | python | {
"resource": ""
} |
q240139 | Info.reset | train | def reset(self):
"""Reset widget to original state."""
self.filename = None
self.dataset = None
# about the recordings
self.idx_filename.setText('Open Recordings...')
self.idx_s_freq.setText('')
self.idx_n_chan.setText('')
self.idx_start_time.setText('')
... | python | {
"resource": ""
} |
q240140 | ExportDatasetDialog.update | train | def update(self):
"""Get info from dataset before opening dialog."""
self.filename = self.parent.info.dataset.filename
self.chan = self.parent.info.dataset.header['chan_name']
for chan in self.chan:
self.idx_chan.addItem(chan) | python | {
"resource": ""
} |
q240141 | create_channels | train | def create_channels(chan_name=None, n_chan=None):
"""Create instance of Channels with random xyz coordinates
Parameters
----------
chan_name : list of str
names of the channels
n_chan : int
if chan_name is not specified, this defines the number of channels
Returns
-------
... | python | {
"resource": ""
} |
q240142 | _color_noise | train | def _color_noise(x, s_freq, coef=0):
"""Add some color to the noise by changing the power spectrum.
Parameters
----------
x : ndarray
one vector of the original signal
s_freq : int
sampling frequency
coef : float
coefficient to apply (0 -> white noise, 1 -> pink, 2 -> br... | python | {
"resource": ""
} |
q240143 | _read_openephys | train | def _read_openephys(openephys_file):
"""Read the channel labels and their respective files from the
'Continuous_Data.openephys' file
Parameters
----------
openephys_file : Path
path to Continuous_Data.openephys inside the open-ephys folder
Returns
-------
int
sampling f... | python | {
"resource": ""
} |
q240144 | _read_date | train | def _read_date(settings_file):
"""Get the data from the settings.xml file
Parameters
----------
settings_file : Path
path to settings.xml inside open-ephys folder
Returns
-------
datetime
start time of the recordings
Notes
-----
The start time is present in the... | python | {
"resource": ""
} |
q240145 | _read_n_samples | train | def _read_n_samples(channel_file):
"""Calculate the number of samples based on the file size
Parameters
----------
channel_file : Path
path to single filename with the header
Returns
-------
int
number of blocks (i.e. records, in which the data is cut)
int
numbe... | python | {
"resource": ""
} |
q240146 | _read_header | train | def _read_header(filename):
"""Read the text header for each file
Parameters
----------
channel_file : Path
path to single filename with the header
Returns
-------
dict
header
"""
with filename.open('rb') as f:
h = f.read(HDR_LENGTH).decode()
header... | python | {
"resource": ""
} |
q240147 | _check_header | train | def _check_header(channel_file, s_freq):
"""For each file, make sure that the header is consistent with the
information in the text file.
Parameters
----------
channel_file : Path
path to single filename with the header
s_freq : int
sampling frequency
Returns
-------
... | python | {
"resource": ""
} |
q240148 | MatchedEvents.all_to_annot | train | def all_to_annot(self, annot, names=['TPd', 'TPs', 'FP', 'FN']):
"""Convenience function to write all events to XML by category, showing
overlapping TP detection and TP standard."""
self.to_annot(annot, 'tp_det', names[0])
self.to_annot(annot, 'tp_std', names[1])
self.to_annot(an... | python | {
"resource": ""
} |
q240149 | convert_sample_to_video_time | train | def convert_sample_to_video_time(sample, orig_s_freq, sampleStamp,
sampleTime):
"""Convert sample number to video time, using snc information.
Parameters
----------
sample : int
sample that you want to convert in time
orig_s_freq : int
sampling frequ... | python | {
"resource": ""
} |
q240150 | _find_channels | train | def _find_channels(note):
"""Find the channel names within a string.
The channel names are stored in the .ent file. We can read the file with
_read_ent and we can parse most of the notes (comments) with _read_notes
however the note containing the montage cannot be read because it's too
complex. So,... | python | {
"resource": ""
} |
q240151 | _find_start_time | train | def _find_start_time(hdr, s_freq):
"""Find the start time, usually in STC, but if that's not correct, use ERD
Parameters
----------
hdr : dict
header with stc (and stamps) and erd
s_freq : int
sampling frequency
Returns
-------
datetime
either from stc or from e... | python | {
"resource": ""
} |
q240152 | _read_ent | train | def _read_ent(ent_file):
"""Read notes stored in .ent file.
This is a basic implementation, that relies on turning the information in
the string in the dict format, and then evaluate it. It's not very flexible
and it might not read some notes, but it's fast. I could not implement a
nice, recursive ... | python | {
"resource": ""
} |
q240153 | _read_packet | train | def _read_packet(f, pos, n_smp, n_allchan, abs_delta):
"""
Read a packet of compressed data
Parameters
----------
f : instance of opened file
erd file
pos : int
index of the start of the packet in the file (in bytes from beginning
of the file)
n_smp : int
num... | python | {
"resource": ""
} |
q240154 | _read_erd | train | def _read_erd(erd_file, begsam, endsam):
"""Read the raw data and return a matrix, converted to microvolts.
Parameters
----------
erd_file : str
one of the .erd files to read
begsam : int
index of the first sample to read
endsam : int
index of the last sample (excluded, ... | python | {
"resource": ""
} |
q240155 | _read_etc | train | def _read_etc(etc_file):
"""Return information about table of content for each erd.
"""
etc_type = dtype([('offset', '<i'),
('samplestamp', '<i'),
('sample_num', '<i'),
('sample_span', '<h'),
('unknown', '<h')])
wit... | python | {
"resource": ""
} |
q240156 | _read_snc | train | def _read_snc(snc_file):
"""Read Synchronization File and return sample stamp and time
Returns
-------
sampleStamp : list of int
Sample number from start of study
sampleTime : list of datetime.datetime
File time representation of sampleStamp
Notes
-----
The synchronizat... | python | {
"resource": ""
} |
q240157 | _read_stc | train | def _read_stc(stc_file):
"""Read Segment Table of Contents file.
Returns
-------
hdr : dict
- next_segment : Sample frequency in Hertz
- final : Number of channels stored
- padding : Padding
stamps : ndarray of dtype
- segment_name : Name of ERD / ETC file segment
... | python | {
"resource": ""
} |
q240158 | _read_vtc | train | def _read_vtc(vtc_file):
"""Read the VTC file.
Parameters
----------
vtc_file : str
path to vtc file
Returns
-------
mpg_file : list of str
list of avi files
start_time : list of datetime
list of start time of the avi files
end_time : list of datetime
... | python | {
"resource": ""
} |
q240159 | Ktlx._read_hdr_dir | train | def _read_hdr_dir(self):
"""Read the header for basic information.
Returns
-------
hdr : dict
- 'erd': header of .erd file
- 'stc': general part of .stc file
- 'stamps' : time stamp for each file
Also, it adds the attribute
_basename : Path... | python | {
"resource": ""
} |
q240160 | Ktlx.return_dat | train | def return_dat(self, chan, begsam, endsam):
"""Read the data based on begsam and endsam.
Parameters
----------
chan : list of int
list of channel indeces
begsam : int
index of the first sample
endsam :
index of the last sample
... | python | {
"resource": ""
} |
q240161 | Ktlx.return_markers | train | def return_markers(self):
"""Reads the notes of the Ktlx recordings.
"""
ent_file = self._filename.with_suffix('.ent')
if not ent_file.exists():
ent_file = self._filename.with_suffix('.ent.old')
try:
ent_notes = _read_ent(ent_file)
except (FileNo... | python | {
"resource": ""
} |
q240162 | BlackRock.return_markers | train | def return_markers(self, trigger_bits=8, trigger_zero=True):
"""We always read triggers as 16bit, but we convert them to 8 here
if requested.
"""
nev_file = splitext(self.filename)[0] + '.nev'
markers = _read_neuralev(nev_file, read_markers=True)
if trigger_bits == 8:
... | python | {
"resource": ""
} |
q240163 | tridi_inverse_iteration | train | def tridi_inverse_iteration(d, e, w, x0=None, rtol=1e-8):
"""Perform an inverse iteration to find the eigenvector corresponding
to the given eigenvalue in a symmetric tridiagonal system.
Parameters
----------
d : ndarray
main diagonal of the tridiagonal system
e : ndarray
offdiagon... | python | {
"resource": ""
} |
q240164 | tridisolve | train | def tridisolve(d, e, b, overwrite_b=True):
"""
Symmetric tridiagonal system solver,
from Golub and Van Loan, Matrix Computations pg 157
Parameters
----------
d : ndarray
main diagonal stored in d[:]
e : ndarray
superdiagonal stored in e[:-1]
b : ndarray
RHS vector
... | python | {
"resource": ""
} |
q240165 | autocov | train | def autocov(x, **kwargs):
"""Returns the autocovariance of signal s at all lags.
Parameters
----------
x : ndarray
axis : time axis
all_lags : {True/False}
whether to return all nonzero lags, or to clip the length of r_xy
to be the length of x and y. If False, then the zero lag c... | python | {
"resource": ""
} |
q240166 | fftconvolve | train | def fftconvolve(in1, in2, mode="full", axis=None):
""" Convolve two N-dimensional arrays using FFT. See convolve.
This is a fix of scipy.signal.fftconvolve, adding an axis argument and
importing locally the stuff only needed for this function
"""
s1 = np.array(in1.shape)
s2 = np.array(in2.shap... | python | {
"resource": ""
} |
q240167 | band_power | train | def band_power(data, freq, scaling='power', n_fft=None, detrend=None,
array_out=False):
"""Compute power or energy acoss a frequency band, and its peak frequency.
Power is estimated using the mid-point rectangle rule. Input can be
ChanTime or ChanFreq.
Parameters
----------
data... | python | {
"resource": ""
} |
q240168 | _create_morlet | train | def _create_morlet(options, s_freq):
"""Create morlet wavelets, with scipy.signal doing the actual computation.
Parameters
----------
foi : ndarray or list or tuple
vector with frequency of interest
s_freq : int or float
sampling frequency of the data
options : dict
with... | python | {
"resource": ""
} |
q240169 | morlet | train | def morlet(freq, s_freq, ratio=5, sigma_f=None, dur_in_sd=4, dur_in_s=None,
normalization='peak', zero_mean=False):
"""Create a Morlet wavelet.
Parameters
----------
freq : float
central frequency of the wavelet
s_freq : int
sampling frequency
ratio : float
ra... | python | {
"resource": ""
} |
q240170 | ChannelDialog.create_widgets | train | def create_widgets(self):
"""Build basic components of dialog."""
self.bbox = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.idx_ok = self.bbox.button(QDialogButtonBox.Ok)
self.idx_cancel = self.bbox.button(QDialogButtonBox.Cancel)
self.idx... | python | {
"resource": ""
} |
q240171 | ChannelDialog.update_groups | train | def update_groups(self):
"""Update the channel groups list when dialog is opened."""
self.groups = self.parent.channels.groups
self.idx_group.clear()
for gr in self.groups:
self.idx_group.addItem(gr['name'])
self.update_channels() | python | {
"resource": ""
} |
q240172 | ChannelDialog.update_channels | train | def update_channels(self):
"""Update the channels list when a new group is selected."""
group_dict = {k['name']: i for i, k in enumerate(self.groups)}
group_index = group_dict[self.idx_group.currentText()]
self.one_grp = self.groups[group_index]
self.idx_chan.clear()
se... | python | {
"resource": ""
} |
q240173 | ChannelDialog.update_cycles | train | def update_cycles(self):
"""Enable cycles checkbox only if there are cycles marked, with no
errors."""
self.idx_cycle.clear()
try:
self.cycles = self.parent.notes.annot.get_cycles()
except ValueError as err:
self.idx_cycle.setEnabled(False)
m... | python | {
"resource": ""
} |
q240174 | _create_data_to_plot | train | def _create_data_to_plot(data, chan_groups):
"""Create data after montage and filtering.
Parameters
----------
data : instance of ChanTime
the raw data
chan_groups : list of dict
information about channels to plot, to use as reference and about
filtering etc.
Returns
... | python | {
"resource": ""
} |
q240175 | _convert_timestr_to_seconds | train | def _convert_timestr_to_seconds(time_str, rec_start):
"""Convert input from user about time string to an absolute time for
the recordings.
Parameters
----------
time_str : str
time information as '123' or '22:30' or '22:30:22'
rec_start: instance of datetime
absolute start time ... | python | {
"resource": ""
} |
q240176 | Traces.read_data | train | def read_data(self):
"""Read the data to plot."""
window_start = self.parent.value('window_start')
window_end = window_start + self.parent.value('window_length')
dataset = self.parent.info.dataset
groups = self.parent.channels.groups
chan_to_read = []
for one_grp... | python | {
"resource": ""
} |
q240177 | Traces.display | train | def display(self):
"""Display the recordings."""
if self.data is None:
return
if self.scene is not None:
self.y_scrollbar_value = self.verticalScrollBar().value()
self.scene.clear()
self.create_chan_labels()
self.create_time_labels()
... | python | {
"resource": ""
} |
q240178 | Traces.create_chan_labels | train | def create_chan_labels(self):
"""Create the channel labels, but don't plot them yet.
Notes
-----
It's necessary to have the width of the labels, so that we can adjust
the main scene.
"""
self.idx_label = []
for one_grp in self.parent.channels.groups:
... | python | {
"resource": ""
} |
q240179 | Traces.create_time_labels | train | def create_time_labels(self):
"""Create the time labels, but don't plot them yet.
Notes
-----
It's necessary to have the height of the time labels, so that we can
adjust the main scene.
Not very robust, because it uses seconds as integers.
"""
min_time =... | python | {
"resource": ""
} |
q240180 | Traces.add_chan_labels | train | def add_chan_labels(self):
"""Add channel labels on the left."""
window_start = self.parent.value('window_start')
window_length = self.parent.value('window_length')
label_width = window_length * self.parent.value('label_ratio')
for row, one_label_item in enumerate(self.idx_label... | python | {
"resource": ""
} |
q240181 | Traces.add_time_labels | train | def add_time_labels(self):
"""Add time labels at the bottom."""
for text, pos in zip(self.idx_time, self.time_pos):
self.scene.addItem(text)
text.setPos(pos) | python | {
"resource": ""
} |
q240182 | Traces.add_traces | train | def add_traces(self):
"""Add traces based on self.data."""
y_distance = self.parent.value('y_distance')
self.chan = []
self.chan_pos = []
self.chan_scale = []
row = 0
for one_grp in self.parent.channels.groups:
for one_chan in one_grp['chan_to_plot']:... | python | {
"resource": ""
} |
q240183 | Traces.display_grid | train | def display_grid(self):
"""Display grid on x-axis and y-axis."""
window_start = self.parent.value('window_start')
window_length = self.parent.value('window_length')
window_end = window_start + window_length
if self.parent.value('grid_x'):
x_tick = self.parent.value('... | python | {
"resource": ""
} |
q240184 | Traces.display_markers | train | def display_markers(self):
"""Add markers on top of first plot."""
for item in self.idx_markers:
self.scene.removeItem(item)
self.idx_markers = []
window_start = self.parent.value('window_start')
window_length = self.parent.value('window_length')
window_end =... | python | {
"resource": ""
} |
q240185 | Traces.step_prev | train | def step_prev(self):
"""Go to the previous step."""
window_start = around(self.parent.value('window_start') -
self.parent.value('window_length') /
self.parent.value('window_step'), 2)
if window_start < 0:
return
self... | python | {
"resource": ""
} |
q240186 | Traces.step_next | train | def step_next(self):
"""Go to the next step."""
window_start = around(self.parent.value('window_start') +
self.parent.value('window_length') /
self.parent.value('window_step'), 2)
self.parent.overview.update_position(window_start) | python | {
"resource": ""
} |
q240187 | Traces.page_prev | train | def page_prev(self):
"""Go to the previous page."""
window_start = (self.parent.value('window_start') -
self.parent.value('window_length'))
if window_start < 0:
return
self.parent.overview.update_position(window_start) | python | {
"resource": ""
} |
q240188 | Traces.page_next | train | def page_next(self):
"""Go to the next page."""
window_start = (self.parent.value('window_start') +
self.parent.value('window_length'))
self.parent.overview.update_position(window_start) | python | {
"resource": ""
} |
q240189 | Traces.go_to_epoch | train | def go_to_epoch(self, checked=False, test_text_str=None):
"""Go to any window"""
if test_text_str is not None:
time_str = test_text_str
ok = True
else:
time_str, ok = QInputDialog.getText(self,
'Go To Epoch',
... | python | {
"resource": ""
} |
q240190 | Traces.line_up_with_epoch | train | def line_up_with_epoch(self):
"""Go to the start of the present epoch."""
if self.parent.notes.annot is None: # TODO: remove if buttons are disabled
error_dialog = QErrorMessage()
error_dialog.setWindowTitle('Error moving to epoch')
error_dialog.showMessage('No score... | python | {
"resource": ""
} |
q240191 | Traces.add_time | train | def add_time(self, extra_time):
"""Go to the predefined time forward."""
window_start = self.parent.value('window_start') + extra_time
self.parent.overview.update_position(window_start) | python | {
"resource": ""
} |
q240192 | Traces.X_more | train | def X_more(self):
"""Zoom in on the x-axis."""
if self.parent.value('window_length') < 0.3:
return
self.parent.value('window_length',
self.parent.value('window_length') * 2)
self.parent.overview.update_position() | python | {
"resource": ""
} |
q240193 | Traces.X_less | train | def X_less(self):
"""Zoom out on the x-axis."""
self.parent.value('window_length',
self.parent.value('window_length') / 2)
self.parent.overview.update_position() | python | {
"resource": ""
} |
q240194 | Traces.X_length | train | def X_length(self, new_window_length):
"""Use presets for length of the window."""
self.parent.value('window_length', new_window_length)
self.parent.overview.update_position() | python | {
"resource": ""
} |
q240195 | Traces.Y_more | train | def Y_more(self):
"""Increase the scaling."""
self.parent.value('y_scale', self.parent.value('y_scale') * 2)
self.parent.traces.display() | python | {
"resource": ""
} |
q240196 | Traces.Y_less | train | def Y_less(self):
"""Decrease the scaling."""
self.parent.value('y_scale', self.parent.value('y_scale') / 2)
self.parent.traces.display() | python | {
"resource": ""
} |
q240197 | Traces.Y_ampl | train | def Y_ampl(self, new_y_scale):
"""Make scaling on Y axis using predefined values"""
self.parent.value('y_scale', new_y_scale)
self.parent.traces.display() | python | {
"resource": ""
} |
q240198 | Traces.Y_wider | train | def Y_wider(self):
"""Increase the distance of the lines."""
self.parent.value('y_distance', self.parent.value('y_distance') * 1.4)
self.parent.traces.display() | python | {
"resource": ""
} |
q240199 | Traces.Y_tighter | train | def Y_tighter(self):
"""Decrease the distance of the lines."""
self.parent.value('y_distance', self.parent.value('y_distance') / 1.4)
self.parent.traces.display() | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.