Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invasive neurophysiology toolbox #516

Merged
merged 46 commits into from
May 3, 2022

Conversation

mpompolas
Copy link
Member

Adding here the repo I've been working on for visibility.

WIP

Automated copying of default config file during installation
Values will be in Volts instead of mV
Specifically for the Kilosort converter: the conversion from double to int16 has been achieved by F/max(max(abs(F))) * 15000.
15000 was selected as the middle of the maximum value that an int16 value can be.  Tried 32678 but Kilosort was giving weird outputs.
So far all the datasets I spike-sorted show reasonable results.
Added .xml converter straight from Brainstorm environment.
Removed .xslx dependency - Kilosort can be used in non-Windows systems now.
Enabled event-dot-visualization on spiking events
Moved Kilosort installation to the plugin manager
Redesigned behavior when manual spike-sorting is performed in Klusters. All the spiking events that belong to electrodes that belong to the shank/Montage will be removed, and then the new manual spiking selections will be added to the link-to-raw file
Added ultramegasort2000 and waveclus spikesorters
Accommodate different starting timepoint than 0
Moved installation to the plugin manager
This allows dots-visualizations along the raw file exploration
Design change - the spikesorters when they finish their unsupervised part automatically attach the events to the link to raw file.
The reason for this design change is that the previous commit allows deletion of the relevant events that are manually spike sorted
In case of .plx, the entire recording is converted to a .bst to avoid the inefficient loading that .plx files have
linspace created precision error on the computation of Fs.
Fixed bug
CONVERT TO LFP: Added option to select the sampling rate of the LFPs.
Substituted the resampling function from Matlab's 'downsample', to BST 'resample'

Bug Fix on demultiplexers - In_spikesorting_rawelectrodes, in_spikesorting_convertforkilosort
@ftadel
Copy link
Member

ftadel commented Mar 14, 2022

fixes #489

Spiking phase locking: display of total number of neurons, don't display omnibus test
Tuning curves: took into account case where a single spike occured.
Fixed display when one of the streams is disabled during acquisition
Intan has inefficient loader (read_Intan_RHD2000). The entire recording is loaded every time by default.
The previous importer (2018) modified Intan's importer to provide efficient importing.
The new importer uses Intan's 2022 importer, but converts the recording to a .bst for efficient loading
update from master and upgrade intan
@mpompolas mpompolas marked this pull request as ready for review March 26, 2022 08:09
Added check for GPU training.
Updated bst_progress calls.
@ftadel
Copy link
Member

ftadel commented Apr 22, 2022

@mpompolas
I uploaded the tutorial dataset to the web server (available from the download page)
I've been editing quite a lot all the processes and the tutorials.

The things I still need to do:

Things that do not work:

  • Display of UltraMegaSort2000 output
  • DespikeLFP option: Requires Optimization toolbox (fminunc) => I could not test it
  • The coordinates of the electrodes are probably a bit random (I took the old channel file you distributed, but this is related to old SCS coordinates...). If you have a solution to export these coordinates in the "world" coordinates of the MRI, that would be great

Things that you can already start working on:

  • Proof-reading the edits I made of the tutorial
  • Make sure that all the spike-sorting functions and conversion to LFP still work on your end, for various test files

I'll keep on working on this in the next few days, please do not push directly anything here.

This was not a "process", but a collection of interactive and shared functions. It was all moved to panel_spikes.m
@ftadel
Copy link
Member

ftadel commented Apr 26, 2022

I'm done for now!

You can now:

  • test all the code,
  • test again all the supported file formats
  • proof-read the documentation.

There are the following remaining issues:

  1. The processes "PSTH per neuron" and "PSTH per electrode" are not documented in the tutorials.
  2. The tutorial section "Raster plot per electrode" should be removed, as it refers to a process that does not exist: https://neuroimage.usc.edu/brainstorm/e-phys/functions#Raster_plots
  3. process_spike_triggered_average.m: lines 163 and 178: (divideBy - size(all_labels,2)) can be negative and lead to complex std values, which screw up completely the displays. Please fix.
  4. I cannot reproduce your figures in the last tutorial: Can you please double-check the results you get with the current version of the code?
    • Noise correlation:
      00-res-corr
    • Spike field coherence:
      00-res-SFC
    • Spike triggered average: I get 70 files and not 53 as documented initially. And I don't see the nice spike illustrated in your figure. Is it because you used the initial recordings and not the LFP epochs, as everywhere else in the tutorial? If you did this and you think it makes sense to illustrate the function, then it needs to be explicit that the user should import both the original recordings and the LFP, for different purposes.
      00-res-avg

It would be great to a have processing script to reproduce all this, but I guess you won't have time to work on this before the end of the week :)

I won't be working on the code again before you're done on your side.

@mpompolas
Copy link
Member Author

Thanks for checking everything out. Working on this now

@sbaillet
Copy link
Collaborator

sbaillet commented Apr 26, 2022 via email

@mpompolas
Copy link
Member Author

mpompolas commented Apr 26, 2022

Pull request has been opened at: mpompolas#13

Tested spikesorters and Derive to LFP with/without Bayesian Denoising.
All good.

Plexon works.
Intan works.
NWB works.
TDT works.

There are the following remaining issues:

The processes "PSTH per neuron" and "PSTH per electrode" are not documented in the tutorials.

My bad. The initial version of the paper had them as Rasterplot per neuron and rasterplot per electrode. After the first revision we changed that to PSTH and in my head these were interchangeable. The new and correct raster plot function was introduced after the revision.
Updated the website to reflect the correct functions.
Also renamed the function PSTH per electrode to PSTH per channel.

The tutorial section "Raster plot per electrode" should be removed, as it refers to a process that does not exist: https://neuroimage.usc.edu/brainstorm/e-phys/functions#Raster_plots

Addressed above.

process_spike_triggered_average.m: lines 163 and 178: (divideBy - size(all_labels,2)) can be negative and lead to complex std values, which screw up completely the displays. Please fix.

Something is off in this function. I can't reproduce the figures I uploaded on the tutorial after your changes. I'll have to check the STD's when I revisit the function again.

Figures reproduction

I cannot reproduce your figures in the last tutorial: Can you please double-check the results you get with the current version of the code?

This is probably due to the fact you used the functions after you did spike-sorting within Brainstorm. I added a wiki-note on the webpage to alert users of this.

Noise correlation:

It's the same.

Spike field coherence:

It's the same.

Spike triggered average: I get 70 files and not 53 as documented initially.

This is due to the fact that after the new spike-sorting, you now have 70 neurons instead of the initial 53 that were assigned to the raw file.
However, as I mentioned before, I still can't reproduce the figure. Something has changed.

TODO

I have to read thoroughly the Tutorial again, but as far as coding goes, the only remaining issue that I see is the function process_spike_triggered_average.m to check for the STDs visualization and confirm that nothing is off after the changes.

@mpompolas
Copy link
Member Author

Update - I run the old process_spike_triggered_average.m on your branch after converting to LFP and I can confirm that the produced figure is the same as what I had on the tutorial, with correct display of the STDs as well, therefore the changes introduced on mpompolas@ae9cd96#diff-a6c4c697a59feda12f423ab7bcc2b2b6aef1465cb6375e90c778f3422d4c5a2b have led to the deviation.

image

image

We just need to focus on the function

@ftadel

This comment was marked as outdated.

@ftadel
Copy link
Member

ftadel commented Apr 29, 2022

Pull request has been opened at: mpompolas#13

I was not sure how you were planning on cascading the merging of the PR, so I integrated these changes directly in here: d55a3b8

I added a script for reproducing the tutorial pipeline and figures automatically: tutorial_ephys.m

I fixed the bugs I introduced in process_spike_triggered_average.m.

I think this is ready for merging!
Please confirm.

@ftadel
Copy link
Member

ftadel commented Apr 30, 2022

Process report obtained from the script tutorial_ephys.m:
Brainstorm process report.pdf

@mpompolas
Copy link
Member Author

Thank you so much for all your help Francois.
Sorry for the delay this week.
I will make the last check tomorrow.

@mpompolas
Copy link
Member Author

mpompolas commented May 2, 2022

Updated STA tutorial page.

You can now merge.

Thank you for all your help @ftadel and @sbaillet

SCRIPT

Last check to do once you merge, is to make sure that the script you created is loaded on the website (note: spiking phase locking and PSTH are not called in the script): https://neuroimage.usc.edu/brainstorm/e-phys/functions#Scripting

FUTURE IMPROVEMENT

One thing that I would suggest to be done at some point in the future, would be to distribute a converted .pl2 file (https://plexon.com/plexutil-4-0-enables-conversion-from-plx-files-to-pl2-files/), instead of a .plx, so users don't get discouraged with the initial waiting time that it takes for converting from .plx to .bst

@ftadel ftadel merged commit f402a42 into brainstorm-tools:master May 3, 2022
@ftadel
Copy link
Member

ftadel commented May 3, 2022

Done!
What a amazing piece of work!

@mpompolas
Thank you so much for the continued efforts on this project over the past years. I'm sure your work will be extremely useful for lots of people around the world.
I wish you the best of luck and success with your new position.
Hopefully some day you'll miss academia and come back to work with us :-)

@sbaillet
Copy link
Collaborator

sbaillet commented May 3, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants