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

Fergil's Miniscope data notes #20

Open
weiglszonja opened this issue Apr 14, 2023 · 5 comments
Open

Fergil's Miniscope data notes #20

weiglszonja opened this issue Apr 14, 2023 · 5 comments
Assignees

Comments

@weiglszonja
Copy link
Collaborator

Calcium (5 objects, ~3 GB)

  • contains a documentation about the experiment and data format
  • behavior data folder is empty (the behavior camera video(s) are missing)
  • miniscope data folder has the following files:

C6-J588_Disc5_msCamAll_ffd.avi > This is a video of all the miniscope ‘Snippets’ (short videos capturing each trial), concatenated together into a single video. The first frame of every snippet is deleted (hence ‘ffd = first frame deleted)
When I open this file in OpenCV, the number of frames are 10262, and the shape of a frame is (240, 376, 3) uint8 dtype.
Screenshot 2023-04-14 at 11 47 31

C6-J588_Disc5_msCamComb_MC.mat > motion corrected video, when opening in MATLAB it has "Mr_8bit" named struct in it with 240 x 376 x 10262 uint8 values.
Screenshot 2023-04-14 at 11 51 25

C6-J588_Disc5_msCamComb_MC_curated_20220605_1722.mat > this file should contain the calcium data, after cells have been identified by CNMF_E, and traces extracted.
When I open this file in MATLAB I can see the "neuron" object however is has a different structure compared to what is expected from the readme:
Screenshot 2023-04-14 at 11 12 43
Since I don't see struct named ‘C’ that would contain the traces of each cell throughout the task.

C6-J588_Disc5_timestampsAllCumulData.mat >
msCamTrialTimestamps defines the first and last frame for each trial. They provided which were reward and shock trials:
CS-Reward trails:
[1, 3, 6, 9, 10, 12, 13, 15, 16, 20, 23, 24, 27, 28, 30],
CS-Shock trails:
[2, 4, 5, 7, 8, 11, 14, 17, 18, 19, 21, 22, 25, 26, 29]
So we know for each frame whether it was a reward or shock trial. > trials table

There are other columns in the file which are not defined in the document:

Screenshot 2023-04-14 at 11 28 38

@CodyCBakerPhD I'm not sure how standard this format is, I expected to be more similar to this, just thinking whether this interface will live in neuroconv or be a custom interface here.

@weiglszonja weiglszonja self-assigned this Apr 14, 2023
@CodyCBakerPhD
Copy link
Member

@CodyCBakerPhD I'm not sure how standard this format is, I expected to be more similar to this, just thinking whether this interface will live in neuroconv or be a custom interface here.

I believe this is externally parsed Miniscope - the native format I thought was the collection of .avi files plus some kind of header, but not MATLAB files that extracted that into arrays

When I open this file in MATLAB I can see the "neuron" object however is has a different structure compared to what is expected from the readme:

(6,1) arrays that have that appearance are the hallmark of MATLAB special encoding schemes. Normally you only see that when reading the .mat file in Python, this is my first time seeing it in MATLAB itself.

But if I had to guess it means that file was written in a certain version of MATLAB and your version is not compatible with it for whatever reason.

What version of MATLAB did you use to try reading it? Can we ask if they knew what version of MATLAB was used to write it?

@weiglszonja
Copy link
Collaborator Author

You're probably right, because it shows up like this in Python:
Screenshot 2023-04-14 at 17 33 25

I'm using MATLAB_R2022b, but I opened MATLAB 5.0 MAT-files before that showed up "normally".
(Actually all the files they have are MATLAB 5.0)

@weiglszonja
Copy link
Collaborator Author

TODO: for this issue try https://github.com/zhoupc/CNMF_E/tree/master/python_wrapper

@weiglszonja
Copy link
Collaborator Author

Created a helper function in MATLAB to load such file that was produced CNMF_E (also adding that folder to the path so MATLAB too can see the 'neuron' struct) and save it in a new file that can be read by Python:

% This is a helper function for repacking a .mat file produced by CNMF_E
% The 'neuron' struct is a Matlab class called Sources2D, so they cannot be directly loaded into Python for further analysis.

function save_neuron(CNMF_E_folder_path, source_filepath, destination_filepath)

    % Add CNMF_E folder to MATLAB search path
    addpath(CNMF_E_folder_path);

    % Load the file
    load(source_filepath, 'neuron');

    neuron = struct(neuron);

    % Save the 'neuron' struct in v7 format
    save(destination_filepath, '-v7', '-struct', 'neuron');

end

@weiglszonja
Copy link
Collaborator Author

TODO: check if segmentation output is compatible with our current CNMF_E extractor

@weiglszonja weiglszonja mentioned this issue Sep 26, 2023
12 tasks
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

No branches or pull requests

2 participants