Beispiel #1
0
    def loadFileRequested(self, files):
        if files is None:
            return

        for f in files:
            if f.shortName().endswith('.mosaic'):
                self.loadStateFile(f.name())
                continue

            if f in self.files:  ## Do not allow loading the same file more than once
                item = self.files[f]
                item.show()  # just show the file; but do not load it
                continue

            if f.isFile():  # add specified files
                item = self.addFile(f)
            elif f.isDir():  # Directories are more complicated
                if self.dataModel.dirType(
                        f
                ) == 'Cell':  #  If it is a cell, just add the cell "Marker" to the plot
                    item = self.canvas.addFile(f)
                else:  # in all other directory types, look for MetaArray files
                    filesindir = glob.glob(f.name() + '/*.ma')
                    for fd in filesindir:  # add files in the directory (ma files: e.g., images, videos)
                        try:
                            fdh = DataManager.getFileHandle(
                                fd)  # open file to get handle.
                        except IOError:
                            continue  # just skip file
                        item = self.addFile(fdh)
                    if len(filesindir) == 0:  # add protocol sequences
                        item = self.addFile(f)
        self.canvas.autoRange()
Beispiel #2
0
    def loadFileRequested(self, files):
        self.canvas = self.getElement('Canvas')
        if files is None:
            return

        for f in files:
            if f in self.files:   ## Do not allow loading the same file more than once
                item = self.files[f]
                item.show()  # just show the file; but do not load it
                continue
            
            if f.isFile():  # add specified files
                item = self.canvas.addFile(f)
            elif f.isDir():  # Directories are more complicated
                if self.dataModel.dirType(f) == 'Cell':  #  If it is a cell, just add the cell "Marker" to the plot
                # note: this breaks loading all images in Cell directory (need another way to do that)
                    item = self.canvas.addFile(f)
                else:  # in all other directory types, look for MetaArray files
                    filesindir = glob.glob(f.name() + '/*.ma')
                    for fd in filesindir:  # add files in the directory (ma files: e.g., images, videos)
                        try:
                            fdh = DataManager.getFileHandle(fd) # open file to get handle.
                        except IOError:
                            continue # just skip file
                        item = self.canvas.addFile(fdh)  # add it
                        self.amendFile(f, item)
                    if len(filesindir) == 0:  # add protocol sequences
                        item = self.canvas.addFile(f)
        self.canvas.selectItem(item)
        self.canvas.autoRange()
    def load_stimulus(self, recording):
        """Return an instance of stimuli.Stimulus"""

        #### I don't know whether I should try to parse this from metadata, or just find square pulses in the command waveform.
        ### I think finding square pulses would be simpler, but makes the assumption that pulses are square. Which is probably usually true.
        ### what if I check the wavegenerator widget data for the function name (pulse) and then findSquarepulses, or raise an exception if it's a different function?
        if isinstance(recording, PatchClampRecording):
            items = []

            fh = DataManager.getFileHandle(recording.meta['file_name'])
            seqDir = PatchEPhys.getParent(fh, 'ProtocolSequence')
            if seqDir is not None:
                dev_info = seqDir.info()['devices'][recording.device_id]

                if dev_info['mode'].lower() == 'vc':
                    units = 'V'
                elif dev_info['mode'].lower() == 'ic':
                    units = 'A'
                else:
                    units = None

                if dev_info['holdingCheck']:
                    items.append(stimuli.Offset(dev_info['holdingSpin']))

                stim_pulses = PatchEPhys.getStimParams(fh)

                for p in stim_pulses:
                    if p['function_type'] == 'pulse':
                        items.append(
                            stimuli.SquarePulse(p['start'], p['length'],
                                                p['amplitude']))
                    elif p['function_type'] == 'pulseTrain':
                        items.append(
                            stimuli.SquarePulseTrain(p['start'],
                                                     p['pulse_number'],
                                                     p['length'],
                                                     p['amplitude'],
                                                     p['period']))

                desc = seqDir.shortName()[:-4]
                return stimuli.Stimulus(desc, items=items, units=units)

        else:
            raise Exception('not implemented yet')