EnnyvanBeest / GeneralNeuropixelAnalysisFunctions

Bunch of scripts that might be useful for other people doing Neuropixel analysis
GNU General Public License v2.0
1 stars 0 forks source link

Using alignatlasdata with AP_histology outputs #1

Open cspurandare opened 9 months ago

cspurandare commented 9 months ago

Hello, I have the probe track obtained from AJ Peters pipeline (https://github.com/petersaj/AP_histology), which gives the structure called probe_ccf as its output. Instead of using the last step of brain region assignment with his pipeline, I am trying to use the alignatlasdata.m function from this repo. I am getting many issues in terms of making the data compatible, but the one I am currently stuck on is in line

for i=2:length(switchpoints{shid}) oripatchobj(shid,i-1) = patch([shid-1 shid shid shid-1],[areapoints{shid}(switchpoints{shid}(i-1)) areapoints{shid}(switchpoints{shid}(i-1)) areapoints{shid}(switchpoints{shid}(i)) areapoints{shid}(switchpoints{shid}(i))],hex2rgb(color_hex(ismember(acronyms,UniqueAreas{shid}{IC{shid}(switchpoints{shid}(i-1))})))); oritextobj(shid,i-1) = text(double(shid-0.5),double(nanmean([areapoints{shid}(switchpoints{shid}(i-1)) areapoints{shid}(switchpoints{shid}(i))])),UniqueAreas{shid}{IC{shid}(switchpoints{shid}(i-1))},'HorizontalAlignment','center'); end

Based on the AJ Peters pipeline, areapoints is a double vector, whereas the code above requires it to be a cell array. ( I lost track of the original line number, because I have been commenting out lines which I could do without.) Is this a known issue?

I created histinfo as histinfo.probe_ccf=probe_ccf(2); where I had 2 neuropixel probes, and I am using KSDir for the 2nd probe. But I am guessing that that was incorrect and I am missing something, because most of the errors I get are related to histinfo either having missing fields or having incorrect format of subfields. Thanks in anticipation, Chinmay

EnnyvanBeest commented 9 months ago

Hi Chinmay,

Just double checking that you have check the function GetHistologyOutput.m (https://github.com/EnnyvanBeest/GeneralNeuropixelAnalysisFunctions/blob/main/Histology/GetHistologyOutput.m) which attempts to prepare different types of histology output files to work with alignatlasdata.m?

If you have and it still doesn't work that could be because I haven't really tried this myself with Andy Peters' output nor do I have data to try and fix it. If you can somehow give me some example data so that I can make an attempt to fix it, that would be great. In that case, please share with my e-mail: ennyvanbeest@gmail.com

Best, Enny

cspurandare commented 9 months ago

Hi Enny, Thank you for your prompt reply. I replied through email, but the data can be accessed from - https://drive.google.com/file/d/1CSgkKjcDhsDZgKdxWhuc0ThKd00ljLsy/view?usp=drive_link

In that zipped folder there is a file called "BrainRegionAssignmentScript_CSP_Feb_2024" which I am using to load the necessary files from Kilosort outputs or AP_Histology based outputs. Thanks again, and do let me know if there are issues, Chinmay

jel0624 commented 1 month ago

I just have a similar question as above. I want to use alignatlasdata.m with the outputs of AP_histology. Is there a general pipeline to convert the data/prepare the data from the probe_ccf obtained from AP_histology to histinfo?

best, Jay

EnnyvanBeest commented 1 month ago

This repository is not monitored, but I've updated the version here and on my end it now works with probe_ccf - at least on single shank probes. Could you please try it out and let me know if it works, then I'll pull it to the main branch. https://github.com/EnnyvanBeest/UnitMatch/tree/WorkInProgress/MATLAB/Histology

jel0624 commented 1 month ago

Thanks! I'm getting an error: Screenshot 2024-10-01 115242

it seems like the output of loadKSdirdoes not output spikeDepths but the code looks for spikeDepths. Is there a different loadKSdir function? Here is what my sp looks like: Screenshot 2024-10-01 115501

EnnyvanBeest commented 1 month ago

there's an additional part of code from the spikes toolbox that loads depths etc.:

[sp.spikeAmps, sp.spikeDepths, sp.templateDepths, sp.templateXpos, sp.tempAmps, sp.tempsUnW, sp.templateDuration, sp.waveforms] = ... templatePositionsAmplitudes(sp.temps, sp.winv, sp.ycoords, sp.xcoords, sp.spikeTemplates, sp.tempScalingAmps); %from the spikes toolbox

EnnyvanBeest commented 1 month ago

For further reference, this is how I typically run the preprocessing:

https://github.com/EnnyvanBeest/UnitMatch/blob/main/MATLAB/DataPreparation/ExtractKilosortData.m#L287

jel0624 commented 1 month ago

Thanks! I didn't know there was another function for this.

Here is another error I got: Screenshot 2024-10-01 121706

Any idea what this might be due to?

EnnyvanBeest commented 1 month ago

that just seems to be an issue with your memory/GPU. Maybe try to replace parfor with for to avoid parallel computing?