Skip to content

individual channel analysis

IndividualChannelInformation (QWidget)

Source code in src/controller/windows/window_individualchannel.py
class IndividualChannelInformation(QWidget):
    session_parent = None
    current_elec = 0
    current_row = 0
    current_col = 0
    recordedTime = None
    has_data = None

    # List of dictionaries containing model packets with electrode info (model, times, spikes, etc).
    # Each packet is for the same electrode, but may have model from different times within recording session
    electrode_packets = []

    # Lists containing values stored in the associated key in electrode_packets dictionaries
    electrode_times = []
    electrode_data = []
    electrode_spikes = []
    electrode_spike_times = []

    individualchannel_charts = {} # dictionary for all different individual channel charts
    individualchannel_charts_update_mapping = {} # dictionary for mapping charts to their update functions

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        uic.loadUi("./src/view/layouts/IndividualChannelWindow.ui", self)

        self.updateElectrodeNum.clicked.connect(self.setElecNum)
        self.updateRC.clicked.connect(self.setRC)

        self.individualchannel_charts = {
            'ChannelTracePlot': self.ChannelTracePlot,
            'AmplitudeHistPlot': self.AmplitudeHistPlot,
            'SpikeRatePlot': self.SpikeRatePlot
        }
        self.individualchannel_charts_update_mapping = {
            'ChannelTracePlot': self.updateChannelTrace,
            'AmplitudeHistPlot': self.updateAmplitudeHist,
            'SpikeRatePlot': self.updateSpikeRate
        }

    def setSessionParent(self, session_parent):
        self.session_parent = session_parent
        # self.setupCharts() TODO figure why this was here

    # Note: do NOT change name from "update"
    def update(self, debug=False):
        start = time.time()
        print("Update individual channels: " + str(self.current_elec))
        self.updateElectrodeData()

        # update the charts
        for chart in self.individualchannel_charts_update_mapping.keys():
            self.individualchannel_charts_update_mapping[chart]()

        idx = map2idx(self.current_row, self.current_col)
        if debug:
            print('std from array stats: ' +
                  str(self.session_parent.LoadedData.df.at[idx, "noise_std"]))
            print("noise mean from array stats: " +
                  str(self.session_parent.LoadedData.df.at[idx, "noise_mean"]))
            print('std from direct calculation: ' + str(np.std(self.electrode_packets[0]["model"])))

        self.totalSamples.setText("Total number of samples: " + str(len(self.electrode_data)))
        self.timeRecorded.setText("Total time recording electrode: "
                                  + str(self.recordedTime)
                                  + "ms")
        self.numSpikes.setText("Number of spikes: " + str(sum(self.electrode_spikes)))
        if debug:
            print('number of spikes from array stats: ' +
                  str(self.session_parent.LoadedData.array_indexed['spike_cnt'][self.current_row][self.current_col]))
        end = time.time()
        if self.session_parent.gui_state['is_mode_profiling']:
            print("Individual Channel update time: " + str(np.round(end-start,2)))

update(self, debug=False)

update(self) update(self, QRect) update(self, QRegion) update(self, int, int, int, int)

Source code in src/controller/windows/window_individualchannel.py
def update(self, debug=False):
    start = time.time()
    print("Update individual channels: " + str(self.current_elec))
    self.updateElectrodeData()

    # update the charts
    for chart in self.individualchannel_charts_update_mapping.keys():
        self.individualchannel_charts_update_mapping[chart]()

    idx = map2idx(self.current_row, self.current_col)
    if debug:
        print('std from array stats: ' +
              str(self.session_parent.LoadedData.df.at[idx, "noise_std"]))
        print("noise mean from array stats: " +
              str(self.session_parent.LoadedData.df.at[idx, "noise_mean"]))
        print('std from direct calculation: ' + str(np.std(self.electrode_packets[0]["model"])))

    self.totalSamples.setText("Total number of samples: " + str(len(self.electrode_data)))
    self.timeRecorded.setText("Total time recording electrode: "
                              + str(self.recordedTime)
                              + "ms")
    self.numSpikes.setText("Number of spikes: " + str(sum(self.electrode_spikes)))
    if debug:
        print('number of spikes from array stats: ' +
              str(self.session_parent.LoadedData.array_indexed['spike_cnt'][self.current_row][self.current_col]))
    end = time.time()
    if self.session_parent.gui_state['is_mode_profiling']:
        print("Individual Channel update time: " + str(np.round(end-start,2)))