def test_qc_extract(self):
     # extract a short lf signal RMS
     for fbin in Path(self.init_folder).rglob('*.lf.bin'):
         ephysqc.extract_rmsmap(fbin, out_folder=self.alf_folder)
         rmsmap_lf = alf.load_object(self.alf_folder, '_ibl_ephysRmsMap_lf')
         spec_lf = alf.load_object(self.alf_folder, '_ibl_ephysSpectra_lf')
         ntimes = rmsmap_lf['times'].shape[0]
         nchannels = rmsmap_lf['rms'].shape[1]
         nfreqs = spec_lf['frequencies'].shape[0]
         # makes sure the dimensions are consistend
         self.assertTrue(rmsmap_lf['rms'].shape == (ntimes, nchannels))
         self.assertTrue(spec_lf['power'].shape == (nfreqs, nchannels))
示例#2
0
from pathlib import Path
import glob, os

import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns

from ibllib.ephys import ephysqc
from ibllib.examples.ibllib import _plot_spectra, _plot_rmsmap
import alf.io
import tkinter.filedialog

# find the correct session to work on
fbinpath = tkinter.filedialog.askdirectory()
os.chdir(fbinpath)
for file in glob.glob("*.lf.bin"):
    print(file)

# make sure you send a path for the time being and not a string
ephysqc.extract_rmsmap(os.path.join(fbinpath, file))

_plot_spectra(fbinpath, 'lf')
_plot_rmsmap(fbinpath, 'lf')
示例#3
0
    axrms.set_ylabel(r'Channel Number')
    plt.colorbar(im, cax=axcb)
    if typ == 'ap':
        im.set_clim(-110, -90)
        axrms.set_xlim(100, 0)
    elif typ == 'lf':
        im.set_clim(-100, -60)
        axrms.set_xlim(500, 0)
    axim.set_xlim(0, 4000)
    axim.set_title(outpath)
    if savefig:
        plt.savefig(outpath / (typ + '_rms.png'), dpi=150)


# ============================== ###
# FIND THE RIGHT FILES, RUN AS SCRIPT
# ============================== ###

if __name__ == '__main__':
    if len(sys.argv) != 2:
        print("Please give the folder path as an input argument!")
    else:
        outpath = Path(sys.argv[1])  # grab from command line input
        fbin = glob.glob(os.path.join(outpath, '*.lf.bin'))
        assert (len(fbin) > 0)
        print('fbin: %s' % fbin)
        # make sure you send a path for the time being and not a string
        ephysqc.extract_rmsmap(Path(fbin[0]))
        _plot_spectra(outpath, 'lf')
        _plot_rmsmap(outpath, 'lf')
示例#4
0
                     aspect='auto',
                     origin='lower',
                     extent=[
                         rmsmap['timestamps'][0], rmsmap['timestamps'][-1], 0,
                         rmsmap['rms'].shape[1]
                     ])
    axim.set_xlabel(r'Time (s)')
    axim.set_ylabel(r'Channel Number')
    plt.colorbar(im, cax=axcb)
    if typ == 'ap':
        im.set_clim(-110, -90)
        axrms.set_xlim(100, 0)
    elif typ == 'lf':
        im.set_clim(-100, -60)
        axrms.set_xlim(500, 0)
    axim.set_xlim(0, 4000)
    if savefig:
        plt.savefig(outpath / (typ + '_rms.png'), dpi=150)


if __name__ == "__main__":
    fbin = Path(
        '/mnt/s1/Data/Subjects/ZM_1735/2019-08-01/001/raw_ephys_data/probe_left/'
        '_iblrig_ephysData.raw_g0_t0.imec.ap.bin')
    ephysqc.extract_rmsmap(
        fbin)  # make sure you send a path for the time being and not a string
    typ = 'lf'
    outpath = fbin.parent
    _plot_spectra(outpath, typ)
    _plot_rmsmap(outpath, typ)