Skip to content

Commit

Permalink
Updated documentation for drift corrected copy
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobpennington committed Jun 12, 2024
1 parent dff0bd4 commit 096bb88
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/gui_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ After loading the data, a heatmap will appear on the right half of the GUI showi
.. image:: https://www.kilosort.org/static/images/gui_run_sorting.png
:width: 600

Not pictured: you can now check the "Save Preprocessed Copy" under the "Run" button to save a filtered, whitened, and drift-corrected copy of the data to "temp_wh.dat" in the results directory. This will also reformat the results for Phy so that the preprocessed copy is used instead of the raw binary file.

If you run into errors or the results look strange, you may need to tweak some of the other settings. A handful are shown below 'number of channels' and 'sampling frequency,' or you can click "Extra settings" to open a new window with more options. Mousing over the name of a setting for about half a second will show a description of what the setting does, along with information about which values are allowed. For more detailed suggestions, see :ref:`parameters`

.. image:: https://www.kilosort.org/static/images/gui_extra_settings.png
Expand Down
29 changes: 28 additions & 1 deletion docs/tutorials/basic_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,34 @@
"settings = {'data_dir': SAVE_PATH.parent, 'n_chan_bin': 385}\n",
"\n",
"ops, st, clu, tF, Wall, similar_templates, is_ref, est_contam_rate = \\\n",
" run_kilosort(settings=settings, probe_name='neuropixPhase3B1_kilosortChanMap.mat')"
" run_kilosort(\n",
" settings=settings, probe_name='neuropixPhase3B1_kilosortChanMap.mat',\n",
" # save_preprocessed_copy=True\n",
" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you want to save a pre-processed copy of the data (including whitening, high-pass filtering, and drift correction), you can set `save_preprocessed_copy = True` in the arguments for `run_kilosort`. Alternatively, `kilosort.io.save_prepocessing` can be used as a standalone utility to generate the same copy from saved sorting results, but this will not update options for Phy. By default, results are saved in the same directory as the binary data in the `kilosort4` subdirectory."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from kilosort.io import save_preprocessing, load_ops\n",
"\n",
"# NOTE: This will only create the .dat file, it will *NOT* update options for Phy.\n",
"# If you want to use this with Phy, you will need to modify `params.py`\n",
"# in the results directory to point to this new file. Additionally,\n",
"# you must set `hp_filtered=True` and `dtype='int16'`.\n",
"ops_path = SAVE_PATH.parent / 'kilosort4' / 'ops.npy'\n",
"ops = load_ops(ops_path)\n",
"save_preprocessing(SAVE_PATH.parent / 'temp_wh.dat', ops, bfile_path=SAVE_PATH)"
]
},
{
Expand Down
11 changes: 9 additions & 2 deletions kilosort/gui/run_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def __init__(self, parent):
self.run_all_button = QtWidgets.QPushButton("Run")
self.spike_sort_button = QtWidgets.QPushButton("Spikesort")
self.save_preproc_check = QtWidgets.QCheckBox("Save Preprocessed Copy")
self.save_preproc_check.setCheckState(QtCore.Qt.CheckState.Unchecked)

self.buttons = [
self.run_all_button
Expand Down Expand Up @@ -52,11 +51,19 @@ def __init__(self, parent):
def setup(self):
self.run_all_button.clicked.connect(self.spikesort)
self.spike_sort_button.clicked.connect(self.spikesort)

self.run_all_button.setSizePolicy(
QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding
)

self.save_preproc_check.setCheckState(QtCore.Qt.CheckState.Unchecked)
preproc_text = """
If enabled, a whitened, filtered, and drift-corrected copy of the
data will be saved to 'temp_wh.dat' in the results directory. This
will also reformat the results for Phy so that the preprocessed copy
is used instead of the raw binary file.
"""
self.save_preproc_check.setToolTip(preproc_text)

self.layout.addWidget(self.run_all_button, 0, 0, 2, 2)
self.layout.addWidget(self.save_preproc_check, 2, 0, 1, 2)

Expand Down

0 comments on commit 096bb88

Please sign in to comment.