Path_For_Experiment Codes - MobsLab/PreProcessing GitHub Wiki
General rationale
Navigating in ever-expanding ocean of recordings could be hard. To overcome the issue, MOBS came up with the idea of maps that are called PathForExperiment
. These are the lists of locations where all the files relevant for a particular project are stored.
The lists are the functions that outputs you paths to all relevant folders. For example, this code will give you the locations of all folders containing BaselineSleep recordings in the project SoMuchScience.
Dir = PathForExperiments_SoMuchScience('BaselineSleep');
To achieve relative comfort in manipulating the paths, several codes exist that treat the paths as sets of objects:
- PathForExperiments - the main list for the project in question;
- RestrictPathForExperiment leaves only the part of the output of PathForExperiment that satisfy to some condition;
- MergePathForExperiment merges (creates a union of) two outputs of PathForExperiment;
- IntersectPathForExperiment creates an intersection of two outputs of PathForExperiment;
- RemoveFromPathForExperiment removes the part of the output of PathForExperiment that satisfy to some condition;
Let's talk about each of them.
PathForExperiments is the basis for your manipulations
PathForExperiments is the script that maps all the nuances of your experiment to the location on your PC. It is created separately for each experimental project.
In our imaginary project SoMuchScience we have three phases: PreSleep, Exploration, PostSleep. Thus,
Dir = PathForExperiments_SoMuchScience('Exploration');
will give you all the folder paths to all Exploration session to you experiment.
Dir
is a Matlab structure that contains five fields:
Dir.path
contains locations of demanded experimental phase on the PC;Dir.ExpeInfo
contains descriptions of each individual dataset packed into ExpeInfo structure (see Preprocessing section);Dir.manipe
contains phase name for each individual dataset (for the simple case of requesting only one experimental phase, it would be cell with the size 1*N, where N is number of dataset locations);Dir.name
contains a cell with mouse numbers in character vector format (f.e., Mouse712);Dir.group
contains affiliations of each dataset to user-defined groups.
PathForExperiments - Main structure
The PathForExperiments is defined like
function Dir=PathForExperimentsERC_SoMuchScience(experiment)
The code
if strcmp(experiment,'Exploration')
% Mouse001
a=a+1;Dir.path{a}{1}='/media/DataMOBsRAIDN/ProjetSoMuchScience/Mouse-001/01012019/Exploration/';
load([Dir.path{a}{1},'ExpeInfo.mat']),Dir.ExpeInfo{a}=ExpeInfo;
% Mouse002
a=a+1;Dir.path{a}{1}='/media/DataMOBsRAIDN/ProjetSoMuchScience/Mouse-002/01012019/Exploration/';
load([Dir.path{a}{1},'ExpeInfo.mat']),Dir.ExpeInfo{a}=ExpeInfo;
% Mouse003
a=a+1;Dir.path{a}{1}='/media/DataMOBsRAIDN/ProjetSoMuchScience/Mouse-003/01012019/Exploration/';
load([Dir.path{a}{1},'ExpeInfo.mat']),Dir.ExpeInfo{a}=ExpeInfo;
end
will create Dir
that contains _Dir.path_
with three folders that correspond to Mouse001, Mouse002 and Mouse 003.
The same piece of code could be created for PreSleep and PostSleep.
PathForExperiments - mouse names and groups
Mouse names are extracted in Dir.name
using this code. It extracts mouse names from the path. Note that it could be changed from extracting it from ExpeInfo.
%% Get mice names
for i=1:length(Dir.path)
Dir.manipe{i}=experiment;
temp=strfind(Dir.path{i}{1},'Mouse-');
if isempty(temp)
Dir.name{i}=Dir.path{i}{1}(strfind(Dir.path{i}{1},'Mouse'):strfind(Dir.path{i}{1},'Mouse')+7);
else
Dir.name{i}=['Mouse',Dir.path{i}{1}(temp+6:temp+8)];
end
end
Groups are extracted in Dir.group
. It extracts groups from the user defined groups. If you have two groups: Group1 and Group2, where Mouse 001 belongs to Group1, and Mouse002 and Mouse003 belong to the Group2, you can write:
Group1=[1 0 0];
Group2=[0 1 1];
Then this code will sort your mice into groups:
%% Get Groups for i=1:length(Dir.path) Dir.manipe{i}=experiment; if strcmp(Dir.manipe{i},'Exploration') for j=1:length(Group1) Dir.group{1}{Group1(j)} = 'Group1'; end for j=1:length(Group2) Dir.group{2}{Group2(j)} = 'Group2'; end end end
For the example of PathForExperiments you can look in PathForExperimentsERC_Dima or PathForExperimentFEAR .
RestrictPathForExperiment
This function restricts your function to mouse number:
Dir=RestrictPathForExperiment(Dir,'nMice',[001 002]);
or the group:
Dir=RestrictPathForExperiment(Dir,'Group','Group1');
MergePathForExperiment
This function can merge two paths from different calls of the function:
Dir = MergePathForExperiment(Dir1,Dir2);
IntersectPathForExperiment
This function creates an intersection of the paths, i.e. removes every location where to Dirs do not match:
Dir = IntersectPathForExperiment(Dir1,Dir2);
RemoveFromPathForExperiment
This function is a mirror counterpart of RestrictPathForExperiment - it removes only the locations that satisfy the condition:
Dir=RemoveFromPathForExperiment(Dir,'nMice',[001 002]);
Dir=RemoveFromPathForExperiment(Dir,'Group','Group1');
This should create enough tools to manipulate your paths in the fashion similar to objects' sets.