Ejemplo n.º 1
0
def read_session(subject, root, experiment, rhino_root):
    jr = JsonIndexReader(rhino_root + '/protocols/r1.json')  # Build JSON reader
    pairs_path = jr.get_value('pairs', subject=subject, experiment=experiment)
    tal_reader = TalReader(filename=pairs_path)
    monopolar_channels = tal_reader.get_monopolar_channels()
    bipolar_channels = tal_reader.get_bipolar_pairs()

    jr = JsonIndexReader(rhino_root + '/protocols/r1.json')  # Build JSON reader
    pairs_path = jr.get_value('pairs', subject=subject, experiment=experiment)
    tal_reader = TalReader(filename=pairs_path)
    monopolar_channels = tal_reader.get_monopolar_channels()
    p_reader = ParamsReader(dataroot=root)
    params = p_reader.read()
    samplerate = params['samplerate']
    print samplerate
    try:
        raw_eeg = EEGReader(session_dataroot=root, channels = monopolar_channels)
        raw_eeg = raw_eeg.read()
        print raw_eeg.shape

    except:
        with h5py.File(root, 'r') as hfile:
            raw_eeg = H5RawReader.H5RawReader.read_h5file(hfile, monopolar_channels,[0])[0]
            print raw_eeg.shape
            raw_eeg = TimeSeriesX.TimeSeriesX(raw_eeg,
                                  dims=['channels', 'start_offsets', 'time'],
                                  coords={
                                      'channels': monopolar_channels,
                                      'start_offsets': [0],
                                      'time': np.arange(raw_eeg.shape[2])*1000/samplerate,
                                      'offsets': ('time',np.arange(raw_eeg.shape[2])),
                                      'samplerate': samplerate})
    return raw_eeg
Ejemplo n.º 2
0
def test_talreader_on_database():
    old_reader = TalReader(filename=osp.join(
        utils.get_rhino_root(),
        'data/eeg/R1234D/tal/R1234D_talLocs_database_bipol.mat'))
    jr = JsonIndexReader(osp.join(utils.get_rhino_root(), 'protocols/r1.json'))
    new_reader = TalReader(
        filename=jr.get_value('pairs', subject='R1234D', experiment='FR1'))
    assert (new_reader.get_bipolar_pairs() == old_reader.get_bipolar_pairs()
            ).all()
    assert (new_reader.get_monopolar_channels() ==
            old_reader.get_monopolar_channels()).all()
Ejemplo n.º 3
0
def test_talreader_on_database():
    old_reader = TalReader(
        filename=
        '/Volumes/rhino_root/data/eeg/R1234D/tal/R1234D_talLocs_database_bipol.mat'
    )
    jr = JsonIndexReader('/Volumes/rhino_root/protocols/r1.json')
    new_reader = TalReader(
        filename=jr.get_value('pairs', subject='R1234D', experiment='FR1'))
    assert new_reader.get_bipolar_pairs() == old_reader.get_bipolar_pairs()
    assert new_reader.get_monopolar_channels(
    ) == old_reader.get_monopolar_channels()
Ejemplo n.º 4
0
def get_bp_tal_struct(sub, montage=0):

    from ptsa.data.readers import TalReader

    #Get electrode information -- bipolar
    tal_path = '/protocols/r1/subjects/' + sub + '/localizations/0/montages/' + str(
        montage) + '/neuroradiology/current_processed/pairs.json'
    tal_reader = TalReader(filename=tal_path)
    tal_struct = tal_reader.read()
    monopolar_channels = tal_reader.get_monopolar_channels()
    bipolar_pairs = tal_reader.get_bipolar_pairs()

    return tal_struct, bipolar_pairs, monopolar_channels
Ejemplo n.º 5
0
def test_talreader_on_database():
    old_reader = TalReader(filename='/Volumes/rhino_root/data/eeg/R1234D/tal/R1234D_talLocs_database_bipol.mat')
    jr = JsonIndexReader('/Volumes/rhino_root/protocols/r1.json')
    new_reader = TalReader(filename=jr.get_value('pairs',subject='R1234D',experiment='FR1'))
    assert new_reader.get_bipolar_pairs() == old_reader.get_bipolar_pairs()
    assert new_reader.get_monopolar_channels() == old_reader.get_monopolar_channels()
Ejemplo n.º 6
0
        t = time.time()
        pow_vec_orig = []
        pow_vec_recon = []
        print(len(recon_files))
        print(len(orig_files))

        assert (len(recon_files) == len(events))

        experiment = 'FR1'
        jr = JsonIndexReader(rhino_root +
                             '/protocols/r1.json')  # Build JSON reader
        pairs_path = jr.get_value('pairs',
                                  subject=subject,
                                  experiment=experiment)
        tal_reader = TalReader(filename=pairs_path)
        monopolar_channels = tal_reader.get_monopolar_channels()
        bipolar_channels = tal_reader.get_bipolar_pairs()

        recon_files = np.sort(recon_files)
        orig_files = np.sort(orig_files)

        data_orig_vec = []
        data_recon_vec = []

        for i, (recon_file,
                orig_file) in enumerate(zip(recon_files, orig_files)):
            if i % 100 == 0:
                print(i)
            fname_recon = subject_dir + recon_file
            fname_orig = subject_dir + orig_file
            bo_orig = se.load(fname_orig)