Beispiel #1
0
    def test_section_sections(self):
        assert (len(self.section.sections) == 0)

        child = self.section.create_section("test section", "electrode")
        assert (child.parent == self.section)

        assert (len(self.section.sections) == 1)

        assert (child in self.section.sections)
        assert (child.id in self.section.sections)
        assert ("notexist" not in self.section.sections)

        assert (child.id == self.section.sections[0].id)
        assert (child.id == self.section.sections[-1].id)

        del self.section.sections[0]

        assert (len(self.section.sections) == 0)

        self.section['easy subsection'] = nix.S('electrode')
        subject = self.section['subject'] = nix.S('subject')

        assert (self.section['subject'] == subject)
        assert (self.section['subject'].id == subject.id)
        assert ('easy subsection'
                in [v.name for k, v in self.section.sections.items()])
        assert ('easy subsection' in self.section.sections)
        assert (self.section['easy subsection'].name == 'easy subsection')
def write_session_metadata(nixfile, block, metadatafile):
    print("INFO/METADATA: Importing from file '%s'" % metadatafile)
    md_sec = nixfile.create_section(block.name, "recording")
    # rec_sec["experimenter"] = "John Doe"
    # rec_sec["startDate"] = "-".join([block.name[:4], block.name[4:6], block.name[6:8]])
    block.metadata = md_sec
    msecs = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    msecs[0] = md_sec

    if sys.version_info[0] < 3:
        mdf = open(metadatafile, 'rb')
    else:
        mdf = open(metadatafile)

    prevcnt = 0
    for mdatrow in csv.reader(mdf):
        # print("---{0}".format(mdatrow))
        for (cnt, mdat) in enumerate(mdatrow):
            if mdat != '':
                # print("***{0}".format(mdat))
                if cnt > prevcnt + 1:
                    break
                
                if len(mdatrow) > cnt + 1:
                    # print("{0}".format(len(mdatrow)))
                    # print("{0} {1} {2}".format(cnt, mdatrow, mdat))
                    msecs[cnt][mdat] = mdatrow[cnt + 1]
                    break
                else:
                    msecs[cnt][mdat] = nix.S(mdat)
                    msecs[cnt + 1] = msecs[cnt][mdat]
                    prevcnt = cnt
                    break
Beispiel #3
0
def write_channel_metadata(section, name, gain=100):
    section[name] = nix.S("eeg_channel")
    section[name]["gain"] = gain
    return section[name]
Beispiel #4
0
def write_subject_metadata(recording_session, name, species="h**o sapiens"):
    recording_session["subject"] = nix.S("subject")
    recording_session["subject"]["name"] = name
    recording_session["subject"]["species"] = species
Beispiel #5
0
def write_eeg_hardware_metadata(block, group):
    src = block.create_source("eeg setup", "eeg.channel_group")
    group.sources.append(src)
    block.metadata["hardware"] = nix.S("recording hardware")
    block.metadata["hardware"]["eeg system"] = nix.S("hardware.eeg")
    return block.metadata["hardware"]["eeg system"]