Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for name, action in self.actions.items(): # toggle
if name not in self.always_enabled:
action.setEnabled(enabled)
if self.model.data: # toggle if specific conditions are met
bads = bool(self.model.current["data"].info["bads"])
self.actions["export_bads"].setEnabled(enabled and bads)
events = self.model.current["events"] is not None
self.actions["export_events"].setEnabled(enabled and events)
if self.model.current["dtype"] == "raw":
annot = bool(self.model.current["data"].annotations)
else:
annot = False
self.actions["export_annotations"].setEnabled(enabled and annot)
self.actions["annotations"].setEnabled(enabled and annot)
locations = has_locations(self.model.current["data"].info)
self.actions["plot_locations"].setEnabled(enabled and locations)
ica = bool(self.model.current["ica"])
self.actions["apply_ica"].setEnabled(enabled and ica)
self.actions["export_ica"].setEnabled(enabled and ica)
self.actions["plot_ica_components"].setEnabled(enabled and ica and
locations)
self.actions["plot_ica_sources"].setEnabled(enabled and ica)
self.actions["interpolate_bads"].setEnabled(enabled and
locations and bads)
self.actions["events"].setEnabled(enabled and events)
self.actions["events_from_annotations"].setEnabled(enabled and
annot)
self.actions["find_events"].setEnabled(
enabled and self.model.current["dtype"] == "raw")
self.actions["epoch_data"].setEnabled(
enabled and events and self.model.current["dtype"] == "raw")
def get_info(self):
"""Get basic information on current data set.
Returns
-------
info : dict
Dictionary with information on current data set.
"""
data = self.current["data"]
fname = self.current["fname"]
ftype = self.current["ftype"]
fsize = self.current["fsize"]
dtype = self.current["dtype"].capitalize()
reference = self.current["reference"]
events = self.current["events"]
locations = has_locations(self.current["data"].info)
ica = self.current["ica"]
length = f"{len(data.times) / data.info['sfreq']:.6g} s"
samples = f"{len(data.times)}"
if self.current["dtype"] == "epochs": # add epoch count
length = f"{self.current['data'].events.shape[0]} x {length}"
samples = f"{self.current['data'].events.shape[0]} x {samples}"
if data.info["bads"]:
nbads = len(data.info["bads"])
nchan = f"{data.info['nchan']} ({nbads} bad)"
else:
nchan = data.info["nchan"]
chans = Counter([mne.io.pick.channel_type(data.info, i)
for i in range(data.info["nchan"])])
# sort by channel type (always move "stim" to end of list)