diff --git a/docs/gui_guide.rst b/docs/gui_guide.rst index e5f20da..ecff87d 100644 --- a/docs/gui_guide.rst +++ b/docs/gui_guide.rst @@ -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 diff --git a/docs/tutorials/basic_example.ipynb b/docs/tutorials/basic_example.ipynb index b6270f2..e7aace3 100644 --- a/docs/tutorials/basic_example.ipynb +++ b/docs/tutorials/basic_example.ipynb @@ -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)" ] }, { diff --git a/kilosort/gui/run_box.py b/kilosort/gui/run_box.py index 223bc93..e9b4e40 100644 --- a/kilosort/gui/run_box.py +++ b/kilosort/gui/run_box.py @@ -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 @@ -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)