hong2p.suite2p module¶
Functions for working with suite2p as part of analysis.
-
hong2p.suite2p.diff_dicts(d1, d2, label1='<', label2='>', header=None)[source]¶ Prints differences between two dictionaries.
- Return type
None
-
hong2p.suite2p.gui_params_equal(ops1, ops2, print_diff=True, **kwargs)[source]¶ Returns whether GUI-settable parameters differ.
- Parameters
ops1 (
Dict[str,Any]) – as returned by load_s2p_opsops2 (
Dict[str,Any]) – to be compared to ops1print_diff (
bool) – whether to print any differences
- Return type
bool
-
hong2p.suite2p.inputs_equal(ops1, ops2, print_diff=True, **kwargs)[source]¶ Returns whether input data and GUI-settable parameters differ.
- Return type
bool
-
hong2p.suite2p.load_s2p_combined_outputs(analysis_dir, **kwargs)[source]¶ Raises IOError if corresponding suite2p output not found (i.e. suite2p needs to be run), LabelsNotModifiedError, or LabelsNotSelectiveError.
-
hong2p.suite2p.load_s2p_masks(s2p_dir)[source]¶ Returns normalized (each sums to 1) cell footprints
- Return type
ndarray
-
hong2p.suite2p.load_s2p_ops(ops_path)[source]¶ - Parameters
ops_path (
Union[str,Path]) – if path does not end with ‘*.npy’, assumed to be a directory containing a file named ‘ops.npy’- Return type
Dict[str,Any]
-
hong2p.suite2p.load_s2p_outputs(plane_or_combined_dir, good_only=True, merge_inputs=False, merge_outputs=False, subset_stat=True, err=False)[source]¶ Returns suite2p outputs, with traces as a DataFrame
Loads outputs from plane_or_combined_dir, tossing data for ROIs marked “not a cell” and ROIs merged to create others (by default).
- Parameters
plane_or_combined_dir (
Union[str,Path]) – directory containing suite2p outputsgood_only – whether to drop data for ROIs marked “not a cell” in suite2p GUI
merge_inputs – whether to drop data for ROIs merged to create other ROIs
merge_outputs – whether to drop data for ROIs created via merging in suite2p
subset_stat – whether to also drop data in roi_stats according to the above criteria.
- Returns
DataFrame w/ ROI numbers and extracted signals stat_dict: dict of ROI num -> suite2ps “stat” ROI data ops: suite2p options merges: dict of ROI nums of ROIs created via merging pointing to a list of the
ROI nums merged to create them. can be used for implementing your own merging strategies.
err: whether to raise errors about ROI “cell / not cell” labels if good_only
- Return type
traces
- Raises
IOError – if suite2p outputs did not exist
LabelsNotModifiedError – if err and good_only and the “cell / not cell” labels have not been modified.
LabelsNotSelectiveError – if err and good_only and no ROIs were marked “not a cell” in suite2p (assumes that some noise ROIs would have been pulled out). This can be caused by setting the threshold to 0 and not modifying the ROIs further manually.
-
hong2p.suite2p.load_stat(s2p_dir)[source]¶ Returns array of dicts, each describing one ROI.
- Return type
ndarray
-
hong2p.suite2p.load_traces(s2p_dir)[source]¶ Returns traces in shape (#-cells, #-timepoints)
- Return type
ndarray
-
hong2p.suite2p.mark_all_suite2p_rois_good(s2p_out_dir)[source]¶ Modify iscell.npy to set all labels (first column) 1.
This is to undo the automatic classification step that I do not want and can not seem to disable. It should be equivalent to entering 0 for the probability threshold in the GUI.
-
hong2p.suite2p.remerge_suite2p_merged(traces, stat_dict, ops, merges, response_stats=None, how='best_plane', renumber=False, verbose=False)[source]¶ Accepts input as the output of load_s2p_outputs
- Parameters
response_stats –
-
hong2p.suite2p.set_suite2p_iscell_label(s2p_out_dir, roi_num, is_good)[source]¶ - Parameters
roi_num (int) – index of ROI to change label of, according to suite2p
s2p_out_dir (str) – must directly contain a single iscell.npy file