_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q240000
Channels.load_channels
train
def load_channels(self, checked=False, test_name=None): """Load channel groups from file. Parameters ---------- test_name : path to file when debugging the function, you can open a channels file from the command line """ chan_name = self.parent.la...
python
{ "resource": "" }
q240001
Channels.save_channels
train
def save_channels(self, checked=False, test_name=None): """Save channel groups to file.""" self.read_group_info() if self.filename is not None: filename = self.filename elif self.parent.info.filename is not None: filename = (splitext(self.parent.info.filename)[0]...
python
{ "resource": "" }
q240002
Channels.reset
train
def reset(self): """Reset all the information of this widget.""" self.filename = None self.groups = [] self.tabs.clear() self.setEnabled(False) self.button_color.setEnabled(False) self.button_del.setEnabled(False) self.button_apply.setEnabled(False) ...
python
{ "resource": "" }
q240003
Spectrum.create
train
def create(self): """Create empty scene for power spectrum.""" self.idx_chan = QComboBox() self.idx_chan.activated.connect(self.display_window) self.idx_fig = QGraphicsView(self) self.idx_fig.scale(1, -1) layout = QVBoxLayout() layout.addWidget(self.idx_chan) ...
python
{ "resource": "" }
q240004
Spectrum.update
train
def update(self): """Add channel names to the combobox.""" self.idx_chan.clear() for chan_name in self.parent.traces.chan: self.idx_chan.addItem(chan_name) if self.selected_chan is not None: self.idx_chan.setCurrentIndex(self.selected_chan) self.selec...
python
{ "resource": "" }
q240005
Spectrum.display_window
train
def display_window(self): """Read the channel name from QComboBox and plot its spectrum. This function is necessary it reads the data and it sends it to self.display. When the user selects a smaller chunk of data from the visible traces, then we don't need to call this function. ...
python
{ "resource": "" }
q240006
Spectrum.display
train
def display(self, data): """Make graphicsitem for spectrum figure. Parameters ---------- data : ndarray 1D vector containing the data only This function can be called by self.display_window (which reads the data for the selected channel) or by the mouse-even...
python
{ "resource": "" }
q240007
Spectrum.add_grid
train
def add_grid(self): """Add axis and ticks to figure. Notes ----- I know that visvis and pyqtgraphs can do this in much simpler way, but those packages create too large a padding around the figure and this is pretty fast. """ value = self.config.value ...
python
{ "resource": "" }
q240008
Spectrum.resizeEvent
train
def resizeEvent(self, event): """Fit the whole scene in view. Parameters ---------- event : instance of Qt.Event not important """ value = self.config.value self.idx_fig.fitInView(value['x_min'], value['y_min'], ...
python
{ "resource": "" }
q240009
Spectrum.reset
train
def reset(self): """Reset widget as new""" self.idx_chan.clear() if self.scene is not None: self.scene.clear() self.scene = None
python
{ "resource": "" }
q240010
detect_Massimini2004
train
def detect_Massimini2004(dat_orig, s_freq, time, opts): """Slow wave detection based on Massimini et al., 2004. Parameters ---------- dat_orig : ndarray (dtype='float') vector with the data for one channel s_freq : float sampling frequency time : ndarray (dtype='float') ...
python
{ "resource": "" }
q240011
select_peaks
train
def select_peaks(data, events, limit): """Check whether event satisfies amplitude limit. Parameters ---------- data : ndarray (dtype='float') vector with data events : ndarray (dtype='int') N x 2+ matrix with peak/trough in second position limit : float low and high limi...
python
{ "resource": "" }
q240012
make_slow_waves
train
def make_slow_waves(events, data, time, s_freq): """Create dict for each slow wave, based on events of time points. Parameters ---------- events : ndarray (dtype='int') N x 5 matrix with start, trough, zero, peak, end samples data : ndarray (dtype='float') vector with the data t...
python
{ "resource": "" }
q240013
_add_halfwave
train
def _add_halfwave(data, events, s_freq, opts): """Find the next zero crossing and the intervening peak and add them to events. If no zero found before max_dur, event is discarded. If peak-to-peak is smaller than min_ptp, the event is discarded. Parameters ---------- data : ndarray (dtype='float...
python
{ "resource": "" }
q240014
Notes.create
train
def create(self): """Create the widget layout with all the annotations.""" """ ------ MARKERS ------ """ tab0 = QTableWidget() self.idx_marker = tab0 tab0.setColumnCount(3) tab0.horizontalHeader().setStretchLastSection(True) tab0.setSelectionBehavior(QAbstractIt...
python
{ "resource": "" }
q240015
Notes.update_notes
train
def update_notes(self, xml_file, new=False): """Update information about the sleep scoring. Parameters ---------- xml_file : str file of the new or existing .xml file new : bool if the xml_file should be a new file or an existing one """ i...
python
{ "resource": "" }
q240016
Notes.enable_events
train
def enable_events(self): """enable slow wave and spindle detection if both annotations and channels are active. """ if self.annot is not None and self.parent.channels.groups: self.action['spindle'].setEnabled(True) self.action['slow_wave'].setEnabled(True) ...
python
{ "resource": "" }
q240017
Notes.display_notes
train
def display_notes(self): """Display information about scores and raters. """ if self.annot is not None: short_xml_file = short_strings(basename(self.annot.xml_file)) self.idx_annotations.setText(short_xml_file) # if annotations were loaded without dataset ...
python
{ "resource": "" }
q240018
Notes.display_stats
train
def display_stats(self): """Display summary statistics about duration in each stage.""" for i, one_stage in enumerate(STAGE_NAME): second_in_stage = self.annot.time_in_stage(one_stage) time_in_stage = str(timedelta(seconds=second_in_stage)) label = self.idx_stage_sta...
python
{ "resource": "" }
q240019
Notes.add_bookmark
train
def add_bookmark(self, time): """Run this function when user adds a new bookmark. Parameters ---------- time : tuple of float start and end of the new bookmark, in s """ if self.annot is None: # remove if buttons are disabled msg = 'No score file...
python
{ "resource": "" }
q240020
Notes.remove_bookmark
train
def remove_bookmark(self, time): """User removes bookmark. Parameters ---------- time : tuple of float start and end of the new bookmark, in s """ self.annot.remove_bookmark(time=time) self.update_annotations()
python
{ "resource": "" }
q240021
Notes.update_dataset_marker
train
def update_dataset_marker(self): """Update markers which are in the dataset. It always updates the list of events. Depending on the settings, it might add the markers to overview and traces. """ start_time = self.parent.overview.start_time markers = [] if self.pa...
python
{ "resource": "" }
q240022
Notes.display_eventtype
train
def display_eventtype(self): """Read the list of event types in the annotations and update widgets. """ if self.annot is not None: event_types = sorted(self.annot.event_types, key=str.lower) else: event_types = [] self.idx_eventtype.clear() evtty...
python
{ "resource": "" }
q240023
Notes.toggle_eventtype
train
def toggle_eventtype(self): """Check or uncheck all event types in event type scroll.""" check = self.check_all_eventtype.isChecked() for btn in self.idx_eventtype_list: btn.setChecked(check)
python
{ "resource": "" }
q240024
Notes.toggle_check_all_eventtype
train
def toggle_check_all_eventtype(self): """Check 'All' if all event types are checked in event type scroll.""" checklist = asarray([btn.isChecked for btn in self.idx_eventtype_list]) if not checklist.all(): self.check_all_eventtype.setChecked(False)
python
{ "resource": "" }
q240025
Notes.get_selected_events
train
def get_selected_events(self, time_selection=None): """Returns which events are present in one time window. Parameters ---------- time_selection : tuple of float start and end of the window of interest Returns ------- list of dict list of...
python
{ "resource": "" }
q240026
Notes.update_annotations
train
def update_annotations(self): """Update annotations made by the user, including bookmarks and events. Depending on the settings, it might add the bookmarks to overview and traces. """ start_time = self.parent.overview.start_time if self.parent.notes.annot is None: ...
python
{ "resource": "" }
q240027
Notes.delete_row
train
def delete_row(self): """Delete bookmarks or event from annotations, based on row.""" sel_model = self.idx_annot_list.selectionModel() for row in sel_model.selectedRows(): i = row.row() start = self.idx_annot_list.property('start')[i] end = self.idx_annot_list...
python
{ "resource": "" }
q240028
Notes.go_to_marker
train
def go_to_marker(self, row, col, table_type): """Move to point in time marked by the marker. Parameters ---------- row : QtCore.int column : QtCore.int table_type : str 'dataset' table or 'annot' table, it works on either """ if table_type =...
python
{ "resource": "" }
q240029
Notes.get_sleepstage
train
def get_sleepstage(self, stage_idx=None): """Score the sleep stage, using shortcuts or combobox.""" if self.annot is None: # remove if buttons are disabled error_dialog = QErrorMessage() error_dialog.setWindowTitle('Error getting sleep stage') error_dialog.showMessag...
python
{ "resource": "" }
q240030
Notes.get_quality
train
def get_quality(self, qual_idx=None): """Get the signal qualifier, using shortcuts or combobox.""" if self.annot is None: # remove if buttons are disabled msg = 'No score file loaded' error_dialog = QErrorMessage() error_dialog.setWindowTitle('Error getting quality')...
python
{ "resource": "" }
q240031
Notes.get_cycle_mrkr
train
def get_cycle_mrkr(self, end=False): """Mark cycle start or end. Parameters ---------- end : bool If True, marks a cycle end; otherwise, it's a cycle start """ if self.annot is None: # remove if buttons are disabled self.parent.statusBar().showMe...
python
{ "resource": "" }
q240032
Notes.remove_cycle_mrkr
train
def remove_cycle_mrkr(self): """Remove cycle marker.""" window_start = self.parent.value('window_start') try: self.annot.remove_cycle_mrkr(window_start) except KeyError: msg = ('The start of the window does not correspond to any cycle ' 'marke...
python
{ "resource": "" }
q240033
Notes.clear_cycle_mrkrs
train
def clear_cycle_mrkrs(self, test=False): """Remove all cycle markers.""" if not test: msgBox = QMessageBox(QMessageBox.Question, 'Clear Cycle Markers', 'Are you sure you want to remove all cycle ' 'markers for this rater?') ...
python
{ "resource": "" }
q240034
Notes.set_stage_index
train
def set_stage_index(self): """Set the current stage in combobox.""" window_start = self.parent.value('window_start') window_length = self.parent.value('window_length') stage = self.annot.get_stage_for_epoch(window_start, window_length) #lg.info('winstart: ' + str(window_start) + ...
python
{ "resource": "" }
q240035
Notes.set_quality_index
train
def set_quality_index(self): """Set the current signal quality in combobox.""" window_start = self.parent.value('window_start') window_length = self.parent.value('window_length') qual = self.annot.get_stage_for_epoch(window_start, window_length, ...
python
{ "resource": "" }
q240036
Notes.markers_to_events
train
def markers_to_events(self, keep_name=False): """Copy all markers in dataset to event type. """ markers = self.parent.info.markers if markers is None: self.parent.statusBar.showMessage('No markers in dataset.') return if not keep_name: ...
python
{ "resource": "" }
q240037
Notes.reset
train
def reset(self): """Remove all annotations from window.""" self.idx_annotations.setText('Load Annotation File...') self.idx_rater.setText('') self.annot = None self.dataset_markers = None # remove dataset marker self.idx_marker.clearContents() self.idx_m...
python
{ "resource": "" }
q240038
MergeDialog.update_event_types
train
def update_event_types(self): """Update event types in event type box.""" self.idx_evt_type.clear() self.idx_evt_type.setSelectionMode(QAbstractItemView.ExtendedSelection) event_types = sorted(self.parent.notes.annot.event_types, key=str.lower) for t...
python
{ "resource": "" }
q240039
ExportEventsDialog.update
train
def update(self): """Update the event types list, info, when dialog is opened.""" self.filename = self.parent.notes.annot.xml_file self.event_types = self.parent.notes.annot.event_types self.idx_evt_type.clear() for ev in self.event_types: self.idx_evt_type.a...
python
{ "resource": "" }
q240040
ExportEventsDialog.save_as
train
def save_as(self): """Dialog for getting name, location of dataset export.""" filename = splitext(self.filename)[0] filename, _ = QFileDialog.getSaveFileName(self, 'Export events', filename) if filename == '': return ...
python
{ "resource": "" }
q240041
_convert_unit
train
def _convert_unit(unit): """Convert different names into SI units. Parameters ---------- unit : str unit to convert to SI Returns ------- str unit in SI format. Notes ----- SI unit such as mV (milliVolt, mVolt), μV (microVolt, muV). """ if unit is None...
python
{ "resource": "" }
q240042
detect_format
train
def detect_format(filename): """Detect file format of the channels based on extension. Parameters ---------- filename : Path name of the filename Returns ------- str file format """ filename = Path(filename) if filename.suffix == '.csv': recformat = 'cs...
python
{ "resource": "" }
q240043
assign_region_to_channels
train
def assign_region_to_channels(channels, anat, parc_type='aparc', max_approx=3, exclude_regions=None): """Assign a brain region based on the channel location. Parameters ---------- channels : instance of wonambi.attr.chan.Channels channels to assign regions to a...
python
{ "resource": "" }
q240044
find_chan_in_region
train
def find_chan_in_region(channels, anat, region_name): """Find which channels are in a specific region. Parameters ---------- channels : instance of wonambi.attr.chan.Channels channels, that have locations anat : instance of wonambi.attr.anat.Freesurfer anatomical information taken f...
python
{ "resource": "" }
q240045
create_sphere_around_elec
train
def create_sphere_around_elec(xyz, template_mri, distance=8, freesurfer=None): """Create an MRI mask around an electrode location, Parameters ---------- xyz : ndarray 3x0 array template_mri : path or str (as path) or nibabel.Nifti (path to) MRI to be used as template distance : ...
python
{ "resource": "" }
q240046
Channels.return_attr
train
def return_attr(self, attr, labels=None): """return the attributes for each channels. Parameters ---------- attr : str attribute specified in Chan.attr.keys() """ all_labels = self.return_label() if labels is None: labels = all_labels ...
python
{ "resource": "" }
q240047
Channels.export
train
def export(self, elec_file): """Export channel name and location to file. Parameters ---------- elec_file : Path or str path to file where to save csv """ elec_file = Path(elec_file) if elec_file.suffix == '.csv': sep = ', ' elif e...
python
{ "resource": "" }
q240048
filter_
train
def filter_(data, axis='time', low_cut=None, high_cut=None, order=4, ftype='butter', Rs=None, notchfreq=50, notchquality=25): """Design filter and apply it. Parameters ---------- ftype : str 'butter', 'cheby1', 'cheby2', 'ellip', 'bessel', 'diff', or 'notch' axis : str, optional...
python
{ "resource": "" }
q240049
convolve
train
def convolve(data, window, axis='time', length=1): """Design taper and convolve it with the signal. Parameters ---------- data : instance of Data the data to filter. window : str one of the windows in scipy, using get_window length : float, optional length of the window ...
python
{ "resource": "" }
q240050
normalize
train
def normalize(x, min_value, max_value): """Normalize value between min and max values. It also clips the values, so that you cannot have values higher or lower than 0 - 1.""" x = (x - min_value) / (max_value - min_value) return clip(x, 0, 1)
python
{ "resource": "" }
q240051
Viz._repr_png_
train
def _repr_png_(self): """This is used by ipython to plot inline. """ app.process_events() QApplication.processEvents() img = read_pixels() return bytes(_make_png(img))
python
{ "resource": "" }
q240052
Viz.save
train
def save(self, png_file): """Save png to disk. Parameters ---------- png_file : path to file file to write to Notes ----- It relies on _repr_png_, so fix issues there. """ with open(png_file, 'wb') as f: f.write(self._repr...
python
{ "resource": "" }
q240053
_make_timestamps
train
def _make_timestamps(start_time, minimum, maximum, steps): """Create timestamps on x-axis, every so often. Parameters ---------- start_time : instance of datetime actual start time of the dataset minimum : int start time of the recording from start_time, in s maximum : int ...
python
{ "resource": "" }
q240054
Overview.update
train
def update(self, reset=True): """Read full duration and update maximum. Parameters ---------- reset: bool If True, current window start time is reset to 0. """ if self.parent.info.dataset is not None: # read from the dataset, if available ...
python
{ "resource": "" }
q240055
Overview.display
train
def display(self): """Updates the widgets, especially based on length of recordings.""" lg.debug('GraphicsScene is between {}s and {}s'.format(self.minimum, self.maximum)) x_scale = 1 / self.parent.value('overview_scale') lg...
python
{ "resource": "" }
q240056
Overview.add_timestamps
train
def add_timestamps(self): """Add timestamps at the bottom of the overview.""" transform, _ = self.transform().inverted() stamps = _make_timestamps(self.start_time, self.minimum, self.maximum, self.parent.value('timestamp_steps')) for stamp, xpos in zip...
python
{ "resource": "" }
q240057
Overview.update_settings
train
def update_settings(self): """After changing the settings, we need to recreate the whole image.""" self.display() self.display_markers() if self.parent.notes.annot is not None: self.parent.notes.display_notes()
python
{ "resource": "" }
q240058
Overview.update_position
train
def update_position(self, new_position=None): """Update the cursor position and much more. Parameters ---------- new_position : int or float new position in s, for plotting etc. Notes ----- This is a central function. It updates the cursor, then upda...
python
{ "resource": "" }
q240059
Overview.display_current
train
def display_current(self): """Create a rectangle showing the current window.""" if self.idx_current in self.scene.items(): self.scene.removeItem(self.idx_current) item = QGraphicsRectItem(0, CURR['pos0'], self.parent....
python
{ "resource": "" }
q240060
Overview.display_markers
train
def display_markers(self): """Mark all the markers, from the dataset. This function should be called only when we load the dataset or when we change the settings. """ for rect in self.idx_markers: self.scene.removeItem(rect) self.idx_markers = [] mar...
python
{ "resource": "" }
q240061
Overview.mark_stages
train
def mark_stages(self, start_time, length, stage_name): """Mark stages, only add the new ones. Parameters ---------- start_time : int start time in s of the epoch being scored. length : int duration in s of the epoch being scored. stage_name : str ...
python
{ "resource": "" }
q240062
Overview.mark_quality
train
def mark_quality(self, start_time, length, qual_name): """Mark signal quality, only add the new ones. Parameters ---------- start_time : int start time in s of the epoch being scored. length : int duration in s of the epoch being scored. qual_name ...
python
{ "resource": "" }
q240063
Overview.mark_cycles
train
def mark_cycles(self, start_time, length, end=False): """Mark cycle bound, only add the new one. Parameters ---------- start_time: int start time in s of the bounding epoch length : int duration in s of the epoch being scored. end: bool ...
python
{ "resource": "" }
q240064
Overview.mousePressEvent
train
def mousePressEvent(self, event): """Jump to window when user clicks on overview. Parameters ---------- event : instance of QtCore.QEvent it contains the position that was clicked. """ if self.scene is not None: x_in_scene = self.mapToScene(event....
python
{ "resource": "" }
q240065
Overview.reset
train
def reset(self): """Reset the widget, and clear the scene.""" self.minimum = None self.maximum = None self.start_time = None # datetime, absolute start time self.idx_current = None self.idx_markers = [] self.idx_annot = [] if self.scene is not None: ...
python
{ "resource": "" }
q240066
_prepare_colors
train
def _prepare_colors(color, values, limits_c, colormap, alpha, chan=None): """Return colors for all the channels based on various inputs. Parameters ---------- color : tuple 3-, 4-element tuple, representing RGB and alpha, between 0 and 1 values : ndarray array with values for each c...
python
{ "resource": "" }
q240067
Viz3.add_surf
train
def add_surf(self, surf, color=SKIN_COLOR, vertex_colors=None, values=None, limits_c=None, colormap=COLORMAP, alpha=1, colorbar=False): """Add surfaces to the visualization. Parameters ---------- surf : instance of wonambi.attr.anat.Surf sur...
python
{ "resource": "" }
q240068
Viz3.add_chan
train
def add_chan(self, chan, color=None, values=None, limits_c=None, colormap=CHAN_COLORMAP, alpha=None, colorbar=False): """Add channels to visualization Parameters ---------- chan : instance of Channels channels to plot color : tuple 3-, 4-...
python
{ "resource": "" }
q240069
select
train
def select(data, trial=None, invert=False, **axes_to_select): """Define the selection of trials, using ranges or actual values. Parameters ---------- data : instance of Data data to select from. trial : list of int or ndarray (dtype='i'), optional index of trials of interest **a...
python
{ "resource": "" }
q240070
resample
train
def resample(data, s_freq=None, axis='time', ftype='fir', n=None): """Downsample the data after applying a filter. Parameters ---------- data : instance of Data data to downsample s_freq : int or float desired sampling frequency axis : str axis you want to apply downsamp...
python
{ "resource": "" }
q240071
fetch
train
def fetch(dataset, annot, cat=(0, 0, 0, 0), evt_type=None, stage=None, cycle=None, chan_full=None, epoch=None, epoch_dur=30, epoch_overlap=0, epoch_step=None, reject_epoch=False, reject_artf=False, min_dur=0, buffer=0): """Create instance of Segments for analysis, complete with info ab...
python
{ "resource": "" }
q240072
get_times
train
def get_times(annot, evt_type=None, stage=None, cycle=None, chan=None, exclude=False, buffer=0): """Get start and end times for selected segments of data, bundled together with info. Parameters ---------- annot: instance of Annotations The annotation file containing events and...
python
{ "resource": "" }
q240073
_longer_than
train
def _longer_than(segments, min_dur): """Remove segments longer than min_dur.""" if min_dur <= 0.: return segments long_enough = [] for seg in segments: if sum([t[1] - t[0] for t in seg['times']]) >= min_dur: long_enough.append(seg) return long_enough
python
{ "resource": "" }
q240074
_concat
train
def _concat(bundles, cat=(0, 0, 0, 0)): """Prepare event or epoch start and end times for concatenation.""" chan = sorted(set([x['chan'] for x in bundles])) cycle = sorted(set([x['cycle'] for x in bundles])) stage = sorted(set([x['stage'] for x in bundles])) evt_type = sorted(set([x['name'] for x in...
python
{ "resource": "" }
q240075
_divide_bundles
train
def _divide_bundles(bundles): """Take each subsegment inside a bundle and put it in its own bundle, copying the bundle metadata.""" divided = [] for bund in bundles: for t in bund['times']: new_bund = bund.copy() new_bund['times'] = [t] divided.append(new_bun...
python
{ "resource": "" }
q240076
_find_intervals
train
def _find_intervals(bundles, duration, step): """Divide bundles into segments of a certain duration and a certain step, discarding any remainder.""" segments = [] for bund in bundles: beg, end = bund['times'][0][0], bund['times'][-1][1] if end - beg >= duration: new_begs = a...
python
{ "resource": "" }
q240077
_create_data
train
def _create_data(data, active_chan, ref_chan=[], grp_name=None): """Create data after montage. Parameters ---------- data : instance of ChanTime the raw data active_chan : list of str the channel(s) of interest, without reference or group ref_chan : list of str reference...
python
{ "resource": "" }
q240078
_select_channels
train
def _select_channels(data, channels): """Select channels. Parameters ---------- data : instance of ChanTime data with all the channels channels : list channels of interest Returns ------- instance of ChanTime data with only channels of interest Notes --...
python
{ "resource": "" }
q240079
create_widgets
train
def create_widgets(MAIN): """Create all the widgets and dockwidgets. It also creates actions to toggle views of dockwidgets in dockwidgets. """ """ ------ CREATE WIDGETS ------ """ MAIN.labels = Labels(MAIN) MAIN.channels = Channels(MAIN) MAIN.notes = Notes(MAIN) MAIN.merge_dialog = Mer...
python
{ "resource": "" }
q240080
create_actions
train
def create_actions(MAIN): """Create all the possible actions.""" actions = MAIN.action # actions was already taken """ ------ OPEN SETTINGS ------ """ actions['open_settings'] = QAction(QIcon(ICON['settings']), 'Settings', MAIN) actions['open_settings'].trigg...
python
{ "resource": "" }
q240081
create_toolbar
train
def create_toolbar(MAIN): """Create the various toolbars.""" actions = MAIN.action toolbar = MAIN.addToolBar('File Management') toolbar.setObjectName('File Management') # for savestate toolbar.addAction(MAIN.info.action['open_dataset']) toolbar.addSeparator() toolbar.addAction(MAIN.channel...
python
{ "resource": "" }
q240082
AnalysisDialog.update_evt_types
train
def update_evt_types(self): """Update the event types list when dialog is opened.""" self.event_types = self.parent.notes.annot.event_types self.idx_evt_type.clear() self.frequency['norm_evt_type'].clear() for ev in self.event_types: self.idx_evt_type.addItem(ev) ...
python
{ "resource": "" }
q240083
AnalysisDialog.toggle_concatenate
train
def toggle_concatenate(self): """Enable and disable concatenation options.""" if not (self.chunk['epoch'].isChecked() and self.lock_to_staging.get_value()): for i,j in zip([self.idx_chan, self.idx_cycle, self.idx_stage, self.idx_evt_type], ...
python
{ "resource": "" }
q240084
AnalysisDialog.toggle_pac
train
def toggle_pac(self): """Enable and disable PAC options.""" if Pac is not None: pac_on = self.pac['pac_on'].get_value() self.pac['prep'].setEnabled(pac_on) self.pac['box_metric'].setEnabled(pac_on) self.pac['box_complex'].setEnabled(pac_on) sel...
python
{ "resource": "" }
q240085
AnalysisDialog.update_nseg
train
def update_nseg(self): """Update the number of segments, displayed in the dialog.""" self.nseg = 0 if self.one_grp: segments = self.get_segments() if segments is not None: self.nseg = len(segments) self.show_nseg.setText('Number of segment...
python
{ "resource": "" }
q240086
AnalysisDialog.check_all_local
train
def check_all_local(self): """Check or uncheck all local event parameters.""" all_local_chk = self.event['global']['all_local'].isChecked() for buttons in self.event['local'].values(): buttons[0].setChecked(all_local_chk) buttons[1].setEnabled(buttons[0].isChecked())
python
{ "resource": "" }
q240087
AnalysisDialog.check_all_local_prep
train
def check_all_local_prep(self): """Check or uncheck all enabled event pre-processing.""" all_local_pp_chk = self.event['global']['all_local_prep'].isChecked() for buttons in self.event['local'].values(): if buttons[1].isEnabled(): buttons[1].setChecked(all_local_pp_ch...
python
{ "resource": "" }
q240088
AnalysisDialog.uncheck_all_local
train
def uncheck_all_local(self): """Uncheck 'all local' box when a local event is unchecked.""" for buttons in self.event['local'].values(): if not buttons[0].get_value(): self.event['global']['all_local'].setChecked(False) if buttons[1].isEnabled() and not buttons[1]...
python
{ "resource": "" }
q240089
AnalysisDialog.get_segments
train
def get_segments(self): """Get segments for analysis. Creates instance of trans.Segments.""" # Chunking chunk = {k: v.isChecked() for k, v in self.chunk.items()} lock_to_staging = self.lock_to_staging.get_value() epoch_dur = self.epoch_param['dur'].get_value() epoch_overl...
python
{ "resource": "" }
q240090
AnalysisDialog.transform_data
train
def transform_data(self, data): """Apply pre-processing transformation to data, and add it to data dict. Parameters --------- data : instance of Segments segments including 'data' (ChanTime) Returns ------- instance of Segments sa...
python
{ "resource": "" }
q240091
AnalysisDialog.save_as
train
def save_as(self): """Dialog for getting name, location of data export file.""" filename = splitext( self.parent.notes.annot.xml_file)[0] + '_data' filename, _ = QFileDialog.getSaveFileName(self, 'Export analysis data', filename, ...
python
{ "resource": "" }
q240092
AnalysisDialog.plot_freq
train
def plot_freq(self, x, y, title='', ylabel=None, scale='semilogy'): """Plot mean frequency spectrum and display in dialog. Parameters ---------- x : list vector with frequencies y : ndarray vector with amplitudes title : str plot title...
python
{ "resource": "" }
q240093
AnalysisDialog.export_pac
train
def export_pac(self, xpac, fpha, famp, desc): """Write PAC analysis data to CSV.""" filename = splitext(self.filename)[0] + '_pac.csv' heading_row_1 = ['Segment index', 'Start time', 'End time', 'Duration', ...
python
{ "resource": "" }
q240094
AnalysisDialog.compute_evt_params
train
def compute_evt_params(self): """Compute event parameters.""" ev = self.event glob = {k: v.get_value() for k, v in ev['global'].items()} params = {k: v[0].get_value() for k, v in ev['local'].items()} prep = {k: v[1].get_value() for k, v in ev['local'].items()} slopes = {k...
python
{ "resource": "" }
q240095
AnalysisDialog.make_title
train
def make_title(self, chan, cycle, stage, evt_type): """Make a title for plots, etc.""" cyc_str = None if cycle is not None: cyc_str = [str(c[2]) for c in cycle] cyc_str[0] = 'cycle ' + cyc_str[0] title = [' + '.join([str(x) for x in y]) for y in [chan, cyc_str, ...
python
{ "resource": "" }
q240096
PlotCanvas.plot
train
def plot(self, x, y, title, ylabel, scale='semilogy', idx_lim=(1, -1)): """Plot the data. Parameters ---------- x : ndarray vector with frequencies y : ndarray vector with amplitudes title : str title of the plot, to appear above it ...
python
{ "resource": "" }
q240097
PlotDialog.create_dialog
train
def create_dialog(self): """Create the basic dialog.""" self.bbox = QDialogButtonBox(QDialogButtonBox.Close) self.idx_close = self.bbox.button(QDialogButtonBox.Close) self.idx_close.pressed.connect(self.reject) btnlayout = QHBoxLayout() btnlayout.addStretch(1) bt...
python
{ "resource": "" }
q240098
make_arousals
train
def make_arousals(events, time, s_freq): """Create dict for each arousal, based on events of time points. Parameters ---------- events : ndarray (dtype='int') N x 5 matrix with start, end samples data : ndarray (dtype='float') vector with the data time : ndarray (dtype='float') ...
python
{ "resource": "" }
q240099
_convert_time_to_sample
train
def _convert_time_to_sample(abs_time, dataset): """Convert absolute time into samples. Parameters ---------- abs_time : dat if it's int or float, it's assumed it's s; if it's timedelta, it's assumed from the start of the recording; if it's datetime, it's assumed it's absolute ti...
python
{ "resource": "" }