MATLAB-Community-Toolboxes-at-INCF / Brain-Observatory-Toolbox

A MATLAB toolbox for interacting with the Allen Brain Observatory
BSD 2-Clause "Simplified" License
19 stars 2 forks source link

access local files via matlab #171

Open cagjony opened 9 months ago

cagjony commented 9 months ago

Hi everyone,

For teaching purposes, I would like to download some nwb files to the external folder and use the getSession function to load files. Whenever I want to run the code below, even though there is a file in the desired location, it tries to download it.


% obtain all sessions in the ephys dataset
sessions = bot.listSessions('ephys');

% obtain all sessions with the desired session_type and then select the first one
desiredSessions = sessions(sessions.session_type == 'brain_observatory_1.1', :);
sess = bot.getSessions(desiredSessions(1, :));

My main motivation is to have a classroom with many computers without internet access. Is there any way to reach the local files and use the same code environment?

ehennestad commented 9 months ago

Hi,

To understand better what is going on, I'd like to ask for some more information.

1) Are you using one of the release versions or are you using any of the branches of this repository? 2) Which operating system / platform are you using? 3) What is your external folder?

This toolbox will create a local folder on your computer (typically in Documents/MATLAB/Brain Observatory Toolbox Cache) and this is were files will be saved. In addition to the downloaded NWB files, there will also be a OC_Manifest.mat and CC_Manifest.mat. Are these files also present in your external folder when you run the code above and the NWB file is re-downloaded?

cagjony commented 9 months ago

Hi,

Thank you for the prompt response,

Answers to the questions,

1- I am using the official toolbox from Matlab 2021 2- I am using 2012 r2 windows server edition 3- external folder is generated automatically when the nwb files are downloaded locally

yes indeed, CC_Manifest.mat and OC_Manifest.mat are downloaded and present in the higher folder 2023-12-16 21_39_58-Clipboard

ehennestad commented 9 months ago

1) Does the Brain Observatory Toolbox show up with a version if you run the ver() command in MATLAB 2) Do you receive any error messages or warnings when the file is redownloaded?

cagjony commented 9 months ago

Yes, I got the error related to my security settings, but I wondered if the file was already in the external folder. Is there a function that allows me to fetch an already downloaded file?

2023-12-16 22_32_59-Clipboard

ehennestad commented 9 months ago

I still do not understand fully what is going on, but did the file download complete before? It is possible that the file is there, but if the download did not complete till the end, it will try to re-download.

Also, I have a suspicion:

if you would type open bot.internal.CloudCacher/websave

And comment out the following line: https://github.com/emeyers/Brain-Observatory-Toolbox/blob/44056406914d69107fb7d3fae494a7ae8839f69e/%2Bbot/%2Binternal/CloudCacher.m#L144

Would it work then?

ehennestad commented 9 months ago

I realize I did not answer this question directly:

I wondered if the file was already in the external folder. Is there a function that allows me to fetch an already downloaded file?

This is the intention of how the toolbox should work, but it seems that in your case something either prevented the file from being downloaded completely, or prevented it from being properly registered as available offline

cagjony commented 9 months ago

I tried commenting our 144 and I also added some breakpoint inside of that function. It turns out, it crashes in cache.m function.

I think it is related to my server's security settings and is there any way to download 1 example dataset where I can have an access to the all optional fields and with using bot.getSessions function I can access it and use the rest of the +bot functions/scripts.

ehennestad commented 9 months ago

Unless I know exactly where the code fails, I am not sure how to advice you best.

If the download is successful, the cache should be updated and the data should be available for later access. If this does not happen, there might be a bug and this should be investigated.

However, if the download is interrupted somehow, then it will be impossible to access the file.

It is possible to download the data directly from the Allen Brain Observatory S3 bucket, but there is no good solution in the Brain Observatory Toolbox for updating the cache to specify that the file is present.