-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from cortex-lab/tl-as-class_outputClasses
Timeline is now an object.
- Loading branch information
Showing
139 changed files
with
4,260 additions
and
17,177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,43 @@ | ||
function subjects = listSubjects() | ||
function subjects = listSubjects(varargin) | ||
%DAT.LISTSUBJECTS Lists recorded subjects | ||
% subjects = DAT.LISTSUBJECTS() Lists the experimental subjects present | ||
% subjects = DAT.LISTSUBJECTS([alyxInstance]) Lists the experimental subjects present | ||
% in experiment info repository ('expInfo'). | ||
% | ||
% Optional input argument of an alyx instance will enable generating this | ||
% list from alyx rather than from the directory structure on zserver | ||
% | ||
% Part of Rigbox | ||
|
||
% 2013-03 CB created | ||
% 2018-01 NS added alyx compatibility | ||
|
||
% The master 'expInfo' repository is the reference for the existence of | ||
% experiments, as given by the folder structure | ||
expInfoPath = dat.reposPath('expInfo', 'master'); | ||
|
||
dirs = file.list(expInfoPath, 'dirs'); | ||
subjects = setdiff(dirs, {'misc'}); %exclude the misc directory | ||
|
||
if nargin>0 && ~isempty(varargin{1}) % user provided an alyx instance | ||
ai = varargin{1}; % an alyx instance | ||
|
||
% get list of all living, non-stock mice from alyx | ||
s = alyx.getData(ai, 'subjects?stock=False&alive=True'); | ||
|
||
% determine the user for each mouse | ||
respUser = cellfun(@(x)x.responsible_user, s, 'uni', false); | ||
|
||
% get cell array of subject names | ||
subjNames = cellfun(@(x)x.nickname, s, 'uni', false); | ||
|
||
% determine which subjects belong to this user | ||
thisUserSubs = sort(subjNames(strcmp(respUser, ai.username))); | ||
|
||
% all the subjects | ||
otherUserSubs = sort(subjNames(~strcmp(respUser, ai.username))); | ||
|
||
% the full, ordered list | ||
subjects = [{'default'}, thisUserSubs, otherUserSubs]'; | ||
else | ||
|
||
% The master 'expInfo' repository is the reference for the existence of | ||
% experiments, as given by the folder structure | ||
expInfoPath = dat.reposPath('expInfo', 'master'); | ||
|
||
dirs = file.list(expInfoPath, 'dirs'); | ||
subjects = setdiff(dirs, {'misc'}); %exclude the misc directory | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,42 @@ | ||
function varargout = parseAlyxInstance(varargin) | ||
%DATA.PARSEALYXINSTANCE Converts input to string for UDP message and back | ||
% [UDP_string] = DATA.PARSEALYXINSTANCE(AlyxInstance, ref) | ||
function [ref, AlyxInstance] = parseAlyxInstance(varargin) | ||
%DAT.PARSEALYXINSTANCE Converts input to string for UDP message and back | ||
% [UDP_string] = DATA.PARSEALYXINSTANCE(ref, AlyxInstance) | ||
% [ref, AlyxInstance] = DATA.PARSEALYXINSTANCE(UDP_string) | ||
% | ||
% The pattern for 'ref' should be '{date}_{seq#}_{subject}', with two | ||
% date formats accepted, either 'yyyy-mm-dd' or 'yyyymmdd'. | ||
% | ||
% AlyxInstance should be a struct with the following fields, all | ||
% containing strings: 'baseURL', 'token', 'username'. | ||
% containing strings: 'baseURL', 'token', 'username'[, 'subsessionURL']. | ||
% | ||
% Part of Rigbox | ||
|
||
% 2017-10 MW created | ||
|
||
if nargin > 1 % in [AlyxInstance, ref] | ||
ai = varargin{1}; % extract AlyxInstance struct | ||
ref = varargin(2); % extract expRef | ||
if nargin > 1 % in [ref, AlyxInstance] | ||
ref = varargin{1}; % extract expRef | ||
ai = varargin{2}; % extract AlyxInstance struct | ||
if isstruct(ai) % if there is an AlyxInstance | ||
ai = orderfields(ai); % alphabetize fields | ||
% remove water requirement remaining field | ||
if isfield(ai, 'water_requirement_remaining') | ||
ai = rmfield(ai, 'water_requirement_remaining'); | ||
end | ||
fname = fieldnames(ai); % get fieldnames | ||
emp = structfun(@isempty, ai); % find empty fields | ||
if any(emp); ai = rmfield(ai, fname(emp)); end % remove the empty fields | ||
c = cellfun(@(fn) ai.(fn), fieldnames(ai), 'UniformOutput', false); % get fieldnames | ||
varargout = strjoin([c; ref],'\'); % join into single string for UDP | ||
else % otherwise just output the expRef | ||
varargout = ref; | ||
ref = strjoin([ref; c],'\'); % join into single string for UDP, otherwise just output the expRef | ||
end | ||
else % in [UDP_string] | ||
C = strsplit(varargin{1},'\'); % split string | ||
varargout{1} = struct('baseURL', C{1}, 'token', C{2}, 'username', C{3}); % reconstruct AlyxInstance | ||
varargout{2} = C{4}; % output expRef | ||
ref = C{1}; % output expRef | ||
if numel(C)>4 % if UDP string included AlyxInstance | ||
AlyxInstance = struct('baseURL', C{2}, 'subsessionURL', C{3},... | ||
'token', C{4}, 'username', C{5}); % reconstruct AlyxInstance | ||
elseif numel(C)>1 % if AlyxInstance has no subsession set | ||
AlyxInstance = struct('baseURL', C{2}, 'token', C{3}, 'username', C{4}); % reconstruct AlyxInstance | ||
else | ||
AlyxInstance = []; % if input was just an expRef, output empty AlyxInstance | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.