def __init__(self, sorting_results_uri=None):
     if sorting_results_uri is None:
         self._sorting_results_uri = _sorting_results_uri
     else:
         self._sorting_results_uri = sorting_results_uri
     x = kc.load_json(self._sorting_results_uri)
     self._df = pd.DataFrame(x)
     print(f"Found {len(self._df)} sorting outputs")
def load_study_records(study_set_file: str) -> StudySetsDict:
    hydrated_sets = kc.load_json(study_set_file)
    assert hydrated_sets is not None
    study_sets: StudySetsDict = {}
    # Make a list of study_set lists, one per StudySet in the source json file.
    for study_set in hydrated_sets['StudySets']:
        name = study_set['name']
        records = make_study_records_from_studyset(study_set)
        study_sets[name] = records
    return study_sets
def parse_workspace_params(parsed: Namespace) -> Params:
    if parsed.dry_run:
        workspace_uri = parsed.workspace_uri
    else:
        workspace_uri = establish_workspace(parsed)
    if ((parsed.sortings_file is None
         and parsed.sortings_file_kachery_uri is None)
            or (parsed.sortings_file is not None
                and parsed.sortings_file_kachery_uri is not None)):
        raise Exception(
            "Exactly one of sortings_file and sortings_file_kachery_uri must be set."
        )
    if parsed.sortings_file is not None:
        with open(parsed.sortings_file) as fp:
            sortings = json.load(fp)
    else:
        sortings = kc.load_json(parsed.sortings_file_kachery_uri)
    return Params(workspace_uri, sortings, parsed.dry_run)
Exemple #4
0
def compute_ground_truth_comparison_hi(recording_uri, gt_uri, firings_uri):
    print_per_verbose(
        1,
        f"Computing ground truth comparison for ground truth {gt_uri} and sorting {firings_uri} (recording {recording_uri})"
    )
    print_per_verbose(3, f'Fetching sample rate from {recording_uri}')
    recording = sv.LabboxEphysRecordingExtractor(recording_uri)
    sample_rate = recording.get_sampling_frequency()
    print_per_verbose(3, f'Got sample rate {sample_rate}')
    print_per_verbose(2, f"Building sorting object for ground truth {gt_uri}")
    gt_firings = kc.load_json(gt_uri)['firings']
    print_per_verbose(2, f"Got ground truth firings {gt_firings}")
    gt_sorting_obj = {
        'sorting_format': 'mda',
        'data': {
            'firings': gt_firings,
            'samplerate': sample_rate
        }
    }
    gt_sorting = sv.LabboxEphysSortingExtractor(gt_sorting_obj)
    print_per_verbose(
        2, f"Building sorting object for sorting with firings {firings_uri}")
    sorting_obj = {
        'sorting_format': 'mda',
        'data': {
            'firings': firings_uri,
            'samplerate': sample_rate
        }
    }
    sorting = sv.LabboxEphysSortingExtractor(sorting_obj)
    print_per_verbose(2, f"Executing ground-truth comparison")
    try:
        gt = compare_with_ground_truth(sorting, gt_sorting)
    except Exception as e:
        print(f"WARNING: Problem in compute_ground_truth_comparison:\n{e}")
        gt = f"Ground truth comparison for gt {gt_uri} and sorting {firings_uri} returned error:\n{e}"
    return gt
Exemple #5
0
def load_sortings(sortingsfile: str) -> List[Dict[str, Any]]:
    hydrated_sortings = kc.load_json(sortingsfile)
    assert hydrated_sortings is not None
    return cast(List[Dict[str, Any]], hydrated_sortings)