Пример #1
0
    def _run_from_folder(cls, output_folder, params, verbose):
        recording = load_extractor(output_folder / 'spikeinterface_recording.json')

        assert isinstance(recording, BinaryRecordingExtractor)
        assert recording.get_num_segments() == 1
        dat_path = recording._kwargs['file_paths'][0]
        print('dat_path', dat_path)

        num_chans = recording.get_num_channels()
        locations = recording.get_channel_locations()
        print(locations)
        print(type(locations))

        # ks_probe is not probeinterface Probe at all
        ks_probe = Bunch()
        ks_probe.NchanTOT = num_chans
        ks_probe.chanMap = np.arange(num_chans)
        ks_probe.kcoords = np.ones(num_chans)
        ks_probe.xc = locations[:, 0]
        ks_probe.yc = locations[:, 1]

        run(
            dat_path,
            params=params,
            probe=ks_probe,
            dir_path=output_folder,
            n_channels=num_chans,
            dtype=recording.get_dtype(),
            sample_rate=recording.get_sampling_frequency(),
        )
Пример #2
0
def run_example():
    run(
        dat_path,
        params=params,
        probe=probe,
        dir_path=dir_path,
        n_channels=probe.NchanTOT,
        dtype=np.int16,
        sample_rate=3e4 #recording.get_sampling_frequency(),
    )
Пример #3
0
def run_spike_sorting_ibl(bin_file):
    _logger = logging.getLogger("pykilosort")
    START_TIME = datetime.datetime.now()

    out_dir = Path("/datadisk/Data/spike_sorting/datasets").joinpath(
        '_'.join(list(bin_file.parts[-6:-3]) + [bin_file.parts[-2]]))
    out_dir.mkdir(exist_ok=True, parents=True)
    add_default_handler(level='DEBUG')
    add_default_handler(
        level='DEBUG',
        filename=out_dir.joinpath(f"{START_TIME.isoformat()}_kilosort.log"))
    files_chmap = Path(
        "/home/olivier/Documents/MATLAB/Kilosort2/configFiles/neuropixPhase3A_kilosortChanMap.mat"
    )
    matdata = Bunch(scipy.io.loadmat(files_chmap))

    probe = Bunch()
    probe.NchanTOT = 385
    # WARNING: indexing mismatch with MATLAB hence the -1
    probe.chanMap = (matdata.chanMap - 1).squeeze()
    probe.xc = matdata.xcoords.squeeze()
    probe.yc = matdata.ycoords.squeeze()
    probe.kcoords = probe.yc * 0 + 1

    try:
        _logger.info(f"Starting KS, output in {out_dir}")
        run(bin_file,
            probe=probe,
            dir_path=out_dir,
            n_channels=385,
            dtype=np.int16,
            sample_rate=3e4)
    except Exception as e:
        _logger.exception("Error in the main loop")

    [_logger.removeHandler(h) for h in _logger.handlers]