From 5657292eeb1ce1a7a5bbfe2afe752e86a5b3f4e6 Mon Sep 17 00:00:00 2001 From: "TORBEN-XPS\\torben" Date: Tue, 1 May 2018 20:25:07 -0400 Subject: [PATCH 1/2] Cellbase-specific preferences are now saved in PREFERENCES variable in Cellbase mat-file. New functions: setcbpref, getcbpref, default_preferences, import_preferences. Updated set/get calls in other functions. --- .../plotting/plot_mclust_projections.m | 4 +- .../optical_tagging/lightcluster.m | 6 +-- .../spike_clusters/LRatio.m | 4 +- .../spike_clusters/LRatio2.m | 4 +- .../spike_clusters/check_channel_validity.m | 2 +- .../spike_clusters/plot_mclust_projections2.m | 4 +- .../MakeTrialEvents2_gonogo.m | 2 +- .../extractSpikeWaveforms.m | 2 +- .../database_functions/analyses/addanalysis.m | 2 +- .../database_functions/analyses/delanalysis.m | 4 +- .../database_functions/analyses/insertdata.m | 2 +- .../database_functions/analyses/setvalue.m | 4 +- .../cellbase/default_preferences.m | 33 ++++++++++++ .../database_functions/cellbase/getcbpref.m | 40 ++++++++++++++ .../cellbase/import_preferences.m | 30 +++++++++++ .../database_functions/cellbase/initcb.m | 28 +++++----- .../database_functions/cellbase/loadcb.m | 8 +-- .../database_functions/cellbase/mountcb.m | 14 +++-- .../database_functions/cellbase/setcbpref.m | 31 +++++++++++ .../database_functions/cellbase/upgradecb.m | 7 ++- .../database_functions/cells/addcell.m | 4 +- .../database_functions/cells/addnewcells.m | 2 +- .../database_functions/cells/delcell.m | 4 +- .../database_functions/cells/findallcells.m | 8 +-- .../conversion/cellid2fnames.m | 22 ++++---- .../conversion/fname2cellid.m | 2 +- CellBase_R2013a/Help/CellBase_functions.html | 4 ++ .../Help/MakeTrialEvents2_gonogo.html | 2 +- CellBase_R2013a/Help/default_preferences.html | 49 +++++++++++++++++ CellBase_R2013a/Help/getcbpref.html | 49 +++++++++++++++++ CellBase_R2013a/Help/import_preferences.html | 52 +++++++++++++++++++ CellBase_R2013a/Help/setcbpref.html | 49 +++++++++++++++++ 32 files changed, 408 insertions(+), 70 deletions(-) create mode 100644 CellBase_R2013a/Functions/database_functions/cellbase/default_preferences.m create mode 100644 CellBase_R2013a/Functions/database_functions/cellbase/getcbpref.m create mode 100644 CellBase_R2013a/Functions/database_functions/cellbase/import_preferences.m create mode 100644 CellBase_R2013a/Functions/database_functions/cellbase/setcbpref.m create mode 100644 CellBase_R2013a/Help/default_preferences.html create mode 100644 CellBase_R2013a/Help/getcbpref.html create mode 100644 CellBase_R2013a/Help/import_preferences.html create mode 100644 CellBase_R2013a/Help/setcbpref.html diff --git a/CellBase_R2013a/AddOns/AnalysisFcn_AK_SPR/plotting/plot_mclust_projections.m b/CellBase_R2013a/AddOns/AnalysisFcn_AK_SPR/plotting/plot_mclust_projections.m index fcb2440..6899b1a 100644 --- a/CellBase_R2013a/AddOns/AnalysisFcn_AK_SPR/plotting/plot_mclust_projections.m +++ b/CellBase_R2013a/AddOns/AnalysisFcn_AK_SPR/plotting/plot_mclust_projections.m @@ -8,7 +8,7 @@ function plot_mclust_projections(cellid) % Only the first light evoked spike is selected for plotting. To account % for drift, only spikes during the stimulation protocol are selected for % plotting. -% SPR 2011-12-28 +% SPR 2011-12-28, TO 5/2018 if nargin < 1, help plot_mclust_projections @@ -47,7 +47,7 @@ function plot_mclust_projections(cellid) prop = 'Energy.fd'; % prop = 'Peak.fd'; -propfn = [getpref('cellbase','cell_pattern') num2str(t) '_' prop]; +propfn = [getcbpref('Spikes_cell_pattern') num2str(t) '_' prop]; propfn_path = [cellid2fnames(cellid,'sess') filesep propfn]; wf_prop = load(propfn_path,'-mat'); wf_prop1 = wf_prop.FeatureData(:,1); diff --git a/CellBase_R2013a/Functions/analysis_functions/optical_tagging/lightcluster.m b/CellBase_R2013a/Functions/analysis_functions/optical_tagging/lightcluster.m index 0d8e386..d58de13 100644 --- a/CellBase_R2013a/Functions/analysis_functions/optical_tagging/lightcluster.m +++ b/CellBase_R2013a/Functions/analysis_functions/optical_tagging/lightcluster.m @@ -21,7 +21,7 @@ % balazs.cshl@gmail.com % 09-May-2012 -% Edit log: BH 5/9/12, 6/20/12 +% Edit log: BH 5/9/12, 6/20/12, TO 5/2018 % Input arguments prs = inputParser; @@ -40,7 +40,7 @@ % Load spikes from Ntt file. Nttfn = cellid2fnames(cellid,'Ntt'); all_spikes = LoadTT_NeuralynxNT(Nttfn); -TIMEFACTOR = getpref('cellbase','timefactor'); % scaling factor to convert spike times into seconds +TIMEFACTOR = getcbpref('Spikes_timefactor'); % scaling factor to convert spike times into seconds all_spikes = all_spikes * TIMEFACTOR; spk = loadcb(cellid,'Spikes'); @@ -71,7 +71,7 @@ valid_channels = check_channel_validity(cellid); % valid channels X = []; for k = 1:length(g.feature_names) - basename = [getpref('cellbase','cell_pattern') num2str(t)]; + basename = [getcbpref('Spikes_cell_pattern') num2str(t)]; propfn = [basename '_' g.feature_names{k}]; % name of feature file (e.g. TT1_Amplitude) sessionpath = cellid2fnames(cellid,'sess'); propfn_path = [sessionpath filesep 'FD']; % where the feature file can be found diff --git a/CellBase_R2013a/Functions/analysis_functions/spike_clusters/LRatio.m b/CellBase_R2013a/Functions/analysis_functions/spike_clusters/LRatio.m index 2e6fb47..827f630 100644 --- a/CellBase_R2013a/Functions/analysis_functions/spike_clusters/LRatio.m +++ b/CellBase_R2013a/Functions/analysis_functions/spike_clusters/LRatio.m @@ -28,7 +28,7 @@ % Load Ntt file Nttfn = cellid2fnames(cellid,'Ntt'); all_spikes = LoadTT_NeuralynxNT(Nttfn); -TIMEFACTOR = getpref('cellbase','timefactor'); % scaling factor to convert spike times into seconds +TIMEFACTOR = getcbpref('Spikes_timefactor'); % scaling factor to convert spike times into seconds all_spikes = all_spikes * TIMEFACTOR; spk = loadcb(cellid,'Spikes'); n = length(all_spikes); % avoid subsampling of spikes due to rounding errors @@ -43,7 +43,7 @@ % Feature matrix X = []; for k = 1:length(feature_names) - basename = [getpref('cellbase','cell_pattern') num2str(t)]; + basename = [getcbpref('Spikes_cell_pattern') num2str(t)]; propfn = [basename '_' feature_names{k}]; % name of feature file (e.g. TT1_Amplitude) sessionpath = cellid2fnames(cellid,'sess'); propfn_path = [sessionpath filesep 'FD']; % where the feature file can be found diff --git a/CellBase_R2013a/Functions/analysis_functions/spike_clusters/LRatio2.m b/CellBase_R2013a/Functions/analysis_functions/spike_clusters/LRatio2.m index c27b50f..11cefb4 100644 --- a/CellBase_R2013a/Functions/analysis_functions/spike_clusters/LRatio2.m +++ b/CellBase_R2013a/Functions/analysis_functions/spike_clusters/LRatio2.m @@ -36,7 +36,7 @@ % Load Ntt file Nttfn = cellid2fnames(cellid,'Ntt'); all_spikes = LoadTT_NeuralynxNT(Nttfn); -TIMEFACTOR = getpref('cellbase','timefactor'); % scaling factor to convert spike times into seconds +TIMEFACTOR = getcbpref('Spikes_timefactor'); % scaling factor to convert spike times into seconds all_spikes = all_spikes * TIMEFACTOR; spk = loadcb(cellid,'Spikes'); n = length(all_spikes); @@ -49,7 +49,7 @@ % Feature matrix X = []; for k = 1:length(g.feature_names) - basename = [getpref('cellbase','cell_pattern') num2str(t)]; + basename = [getcbpref('Spikes_cell_pattern') num2str(t)]; propfn = [basename '_' g.feature_names{k}]; % name of feature file (e.g. TT1_Amplitude) sessionpath = cellid2fnames(cellid,'sess'); propfn_path = [sessionpath filesep 'FD']; % where the feature file can be found diff --git a/CellBase_R2013a/Functions/analysis_functions/spike_clusters/check_channel_validity.m b/CellBase_R2013a/Functions/analysis_functions/spike_clusters/check_channel_validity.m index edcee56..f907f90 100644 --- a/CellBase_R2013a/Functions/analysis_functions/spike_clusters/check_channel_validity.m +++ b/CellBase_R2013a/Functions/analysis_functions/spike_clusters/check_channel_validity.m @@ -13,7 +13,7 @@ [r,s,t,u] = cellid2tags(cellid); % Load Energy -propfn = [getpref('cellbase','cell_pattern') num2str(t) '_Energy']; +propfn = [getcbpref('Spikes_cell_pattern') num2str(t) '_Energy']; propfn_path = [cellid2fnames(cellid,'sess') filesep 'FD']; if ~isdir(propfn_path) propfn_path = cellid2fnames(cellid,'sess'); diff --git a/CellBase_R2013a/Functions/analysis_functions/spike_clusters/plot_mclust_projections2.m b/CellBase_R2013a/Functions/analysis_functions/spike_clusters/plot_mclust_projections2.m index cce15b5..e906748 100644 --- a/CellBase_R2013a/Functions/analysis_functions/spike_clusters/plot_mclust_projections2.m +++ b/CellBase_R2013a/Functions/analysis_functions/spike_clusters/plot_mclust_projections2.m @@ -66,7 +66,7 @@ % Load spikes from Ntt file. Nttfn = cellid2fnames(cellid,'Ntt'); all_spikes = LoadTT_NeuralynxNT(Nttfn); -TIMEFACTOR = getpref('cellbase','timefactor'); % scaling factor to convert spike times into seconds +TIMEFACTOR = getcbpref('Spikes_timefactor'); % scaling factor to convert spike times into seconds all_spikes = all_spikes * TIMEFACTOR; val_spk_i = [find(all_spikes >= pon(1),1,'first') ... find(all_spikes <= pon(end),1,'last')]; % consider spikes only within the stimulation protocol to account for drift @@ -101,7 +101,7 @@ [r,s,t] = cellid2tags(cellid); for k = 1:length(g.feature_names) prop = [g.feature_names{k} '.fd']; - propfn = [getpref('cellbase','cell_pattern') num2str(t) '_' prop]; + propfn = [getcbpref('Spikes_cell_pattern') num2str(t) '_' prop]; sessionpath = cellid2fnames(cellid,'sess'); propfn_path = [sessionpath filesep 'FD']; % where the feature file can be found if ~isdir(propfn_path) diff --git a/CellBase_R2013a/Functions/data_processing_functions/MakeTrialEvents2_gonogo.m b/CellBase_R2013a/Functions/data_processing_functions/MakeTrialEvents2_gonogo.m index a31c370..fe9963c 100644 --- a/CellBase_R2013a/Functions/data_processing_functions/MakeTrialEvents2_gonogo.m +++ b/CellBase_R2013a/Functions/data_processing_functions/MakeTrialEvents2_gonogo.m @@ -9,7 +9,7 @@ function MakeTrialEvents2_gonogo(sessionpath,varargin) % file becomes the primary store of behavioral data for a particular % session; it is retrieved by LOADCB via CELLID2FNAMES. This default % file name is one of the preference settings of CellBase - type -% getpref('cellbase','session_filename'); +% getcbpref('TrialEvents_filename'); % % MAKETRIALEVENTS2_GONOGO(SESSIONPATH,'StimNttl',TTL) specifies the TTL % channel which serves as the basis for synchronization. diff --git a/CellBase_R2013a/Functions/data_processing_functions/extractSpikeWaveforms.m b/CellBase_R2013a/Functions/data_processing_functions/extractSpikeWaveforms.m index c1c1af1..dafaf73 100644 --- a/CellBase_R2013a/Functions/data_processing_functions/extractSpikeWaveforms.m +++ b/CellBase_R2013a/Functions/data_processing_functions/extractSpikeWaveforms.m @@ -37,7 +37,7 @@ % Load waveform data (Ntt file) Nttfile = cellid2fnames(cellid,'ntt'); -TIMEFACTOR = getpref('cellbase','timefactor'); % scaling factor to convert spike times into seconds +TIMEFACTOR = getcbpref('Spikes_timefactor'); % scaling factor to convert spike times into seconds [all_spikes all_waves] = LoadTT_NeuralynxNT(Nttfile); [junk junk2 evoked_inx] = intersect(SpikeTimes,all_spikes*TIMEFACTOR); if ~isequal(junk,SpikeTimes) % internal check for spike times diff --git a/CellBase_R2013a/Functions/database_functions/analyses/addanalysis.m b/CellBase_R2013a/Functions/database_functions/analyses/addanalysis.m index 19210a8..b9509cc 100644 --- a/CellBase_R2013a/Functions/database_functions/analyses/addanalysis.m +++ b/CellBase_R2013a/Functions/database_functions/analyses/addanalysis.m @@ -163,7 +163,7 @@ function addanalysis(funhandle,varargin) copyfile(cb,backup_name) % make backup before overwriting % SAVE CELLBASE -save(getpref('cellbase','fname'),'TheMatrix','ANALYSES','CELLIDLIST') +save(getpref('cellbase','fname'),'TheMatrix','ANALYSES','CELLIDLIST','PREFERENCES') % ------------------------------------------------------------------------- function ts = timestamp diff --git a/CellBase_R2013a/Functions/database_functions/analyses/delanalysis.m b/CellBase_R2013a/Functions/database_functions/analyses/delanalysis.m index 4ad53ac..9dcea4c 100644 --- a/CellBase_R2013a/Functions/database_functions/analyses/delanalysis.m +++ b/CellBase_R2013a/Functions/database_functions/analyses/delanalysis.m @@ -9,7 +9,7 @@ function delanalysis(funhandle) % % See also ADDANALYSIS and FINDANALYSIS. -% Edit log: BH 6/21/12 +% Edit log: BH 6/21/12, TO 5/2018 % Load CellBase load(getpref('cellbase','fname')); @@ -73,4 +73,4 @@ function delanalysis(funhandle) dsr = regexprep(dsr,':','_'); backup_name = fullfile(pth,[fnm '_' dsr ext]); copyfile(cb,backup_name) % make backup before overwriting -save(getpref('cellbase','fname'),'TheMatrix','ANALYSES','CELLIDLIST') \ No newline at end of file +save(getpref('cellbase','fname'),'TheMatrix','ANALYSES','CELLIDLIST','PREFERENCES') \ No newline at end of file diff --git a/CellBase_R2013a/Functions/database_functions/analyses/insertdata.m b/CellBase_R2013a/Functions/database_functions/analyses/insertdata.m index 6422b5b..0f841e3 100644 --- a/CellBase_R2013a/Functions/database_functions/analyses/insertdata.m +++ b/CellBase_R2013a/Functions/database_functions/analyses/insertdata.m @@ -1 +1 @@ -function varargout = insertdata(varargin) %INSERTDATA Insert data into CellBase directly. % NF = INSERTDATA(DATA,PARAM,VALUE) inserts DATA into TheMatrix % and ANALYSES (see CellBase documentation). It optionally returns the % list of entries in DATA which did not provide a match with CELLIDLIST % (NF). % Input arguments: % DATA - Either a Matlab variable or a full pathname to a .mat or an % Excel file. It can optionally contain a header row with % 'property_names' in the first column and corresponding property % names for data columns. First column should contain cellIDs. If % property names are added as both input argument and data % header, the user is forced to choose which one to use. % 'TYPE', T - Parameter indicating whether an analysis or a set of % properties are added. T should start with the letter 'a' or 'p' % accordingly. % 'NAME', NM - Name of the analysis or properti(es). For analysis: % it should be the name of a valid m file. For properties: either % a character array (one property) or a cell array of strings % (multiple properties). % 'INPUT_ARGUMENTS', LS1 - Input arguments for analysis, cell array. % 'OUTPUT_ARGUMENTS', LS2 - Names of output arguments for analysis, % cell array of strings. This determines the property names when % an analysis is added. % % The number of properties or output arguments (in case of adding values % to an analysis) must match the number of data columns (number of all % columns minus one) in DATA. % % Missing input arguments are asked for interactively. If DATA is empty, % the user has to browse for the data file. If 'Cancel' is selected for % browsing result, data values will interactively be prompted for % according to a selected tag type (animal, session, tetrode or cell). % % If a property or an analysis is already added to CellBase, the user is % asked whether to overwrite previous data. An analysis is only % considered the same if the name of the m file and both the list of % input and output arguments are the same. If the data is overwritten, % the timestamp property in ANALYSES is updated. % % New data is inserted into TheMatrix and ANALYSES according to the % corresponding cellIDs. A backup of the previous cellbase file is stored % before overwriting. % % Examples: % insertdata(data,'type','analysis','name','LRatio','input_arguments',... % {{'Amplitude','Energy'}},'output_arguments',{'ID_amp','Lr_amp'}) % not_found = insertdata([],'type','prop','name','validity'); % insertdata('c:\Balazs\_analysis\NB\tagging\validity.xls','type',... % 'prop','name','validity') % insertdata('c:\Balazs\_analysis\NB\tagging2\spikeshapecorr.xls','type',... % 'analysis','name','spikeshapecorr') % % See also ADDANALYSIS and RUNANALYSIS. % Edit log: AK,SPR 5/10; BH 5/3/12 % Input arguments prs = inputParser; addOptional(prs,'data',[],@(s)isempty(s)||iscell(s)||ischar(s)) addParamValue(prs,'type','',@(s)ismember(s(1),{'p','a'})) % property or analysis addParamValue(prs,'name',{},@(s)ischar(s)||iscell(s)) % name of properties or analysis function addParamValue(prs,'input_arguments',{},@iscell) % name of input arguments for analysis function addParamValue(prs,'output_arguments',{},@(s)ischar(s)||iscell(s)) % name of output arguments for analysis function - used for proporty names if type=analysis parse(prs,varargin{:}) g = prs.Results; % If no options specified, ask everything % Property or analysis? if isempty(g.type) pora = ''; while ~ismember(pora,{'p','a'}) pora = input('\n Do you want to insert a property or an analysis? p/a ','s'); end else pora = g.type(1); end % Property names or mfile name switch pora case 'p' % property names if isempty(g.name) tinp = input('\n Please enter the property names you want to add. ','s'); propnames = strread(tinp,'%s','delimiter',', ')'; else propnames = g.name; end if ischar(propnames) % convert to cell if there's only one property propnames = {propnames}; end funhandle = @insertdata; % for properties, the function handle is 'insertdata' arglist = {}; % a property does not have arguments % (except for manually entered properties, where it is the 'option', see below) case 'a' % mfile name if isempty(g.name) wi = 0; while ~wi mfile = input('\n Please enter the name of the analysis function. ','s'); funhandle = str2func(mfile); % check analysis function funinfo = functions(funhandle); if ~isempty(funinfo.file) fprintf('\n%s\n','Analysis file was loacated: ') disp(funinfo.file) wi = 1; else fprintf('\n%s\n','INSERTDATA: Function is not valid.') end end else mfile = g.name; funhandle = str2func(mfile); end if isempty(g.input_arguments) % mfile input arguments tinp = input(['\n Please enter the list of input arguments for '... mfile ',\n or press Enter for no arguments. ']); arglist = tinp; else arglist = g.input_arguments; end if isempty(g.output_arguments) % mfile output arguments (properties) tinp = input(['\n Please enter the list of output arguments for '... mfile '. '],'s'); propnames = strread(tinp,'%s','delimiter',', ')'; else propnames = g.output_arguments; end if ischar(propnames) % convert to cell if there's only one output argument propnames = {propnames}; end end % Load data if isempty(g.data) [filename, pathname] = uigetfile( ... {'*.mat;*.xls;*.xlsx','Supported formats (*.mat,*.xls,*.xlsx)';... '*.mat','MAT-files (*.mat)'; ... '*.xls;*.xlsx','Excel files (*.xls,*.xlsx)'; ... '*.*', 'All Files (*.*)'}, ... 'Select Datafile'); % select data file fullpth = fullfile(pathname,filename); vardata = read_data(fullpth); else if ischar(g.data) vardata = read_data(g.data); else vardata = g.data; end end % Load CellBase load(getpref('cellbase','fname')); % Check data if ~isempty(vardata) if isequal(vardata{1,1},'property_names') % property names in data header newpropnames = vardata(1,2:end); vardata = vardata(2:end,:); if isempty(propnames) propnames = newpropnames; fprintf('\n%s','Using property names detected in data header:') disp(propnames) end if ~isequal(propnames,newpropnames) % optionally overwrite input argument with header useheader = input('\nUse property/argument names of data header? (y/n) ','s'); while ~ismember(useheader,{'y','n'}) useheader = input('\nUse property/argument names of data header? (y/n) ','s'); end if isequal(useheader,'y') propnames = newpropnames; fprintf('\n%s','Using property names detected in data header:') disp(propnames) end end end infinx = cellfun(@(s)isequal('Inf',s),vardata); % convert 'Inf' to Inf vardata(infinx) = {Inf}; infinx = cellfun(@(s)isequal('-Inf',s),vardata); vardata(infinx) = {-Inf}; naninx = cellfun(@(s)isequal('NaN',s),vardata); % convert 'NaN' to NaN vardata(naninx) = {NaN}; if ~isequal(length(propnames),size(vardata,2)-1) error('INSERTDATA: Data does not match the number of properties.') end end % If no data, add values one by one if isempty(vardata) option = input(['\nYou will be prompted to add values manually. \n'... 'Would you like to add separate value for each \n'... 'animal/session/tetrode/cell? '],'s'); if ~(strncmp(option,'ani',3) || strncmp(option,'rat',3) || ... strncmp(option,'ses',3) || strncmp(option,'tet',3) || ... strncmp(option,'cel',3)) error('INSERTDATA: unknown option.'); else arglist = {option}; % store the chosen option in the argument field end % Add values for each properties vardata = {}; % initalize for prp = 1:length(propnames) propname = propnames{prp}; lastcellpos = 0; % Create list to display list = listtag(option); % find all relevant cell classes if strncmp(option,'session',3) list2add = strcat(char(list(:,1)),'_',char(list(:,2))); elseif strncmp(option,'tetrode',3) list2add = strcat(char(list(:,1)),'_',char(list(:,2)),'_',char(list(:,3))); else % option = rat or cell list2add = char(list); end % Type values fprintf('\n%s%s%s\n','Insert values for ',propname,'.') for i = 1:size(list2add,1) value = prompt_for_value(list2add(i,:)); if strncmp(option,'session',3) pos = findcellpos('rat',list(i,1),'session',list(i,2)); elseif strncmp(option,'tetrode',3) pos = findcellpos('rat',list(i,1),'session',list(i,2),'tetrode',list(i,3)); elseif strncmp(option,'rat',3) pos = findcellpos('rat',list(i)); elseif strncmp(option,'animal',3) pos = findcellpos('animal',list(i)); else pos = findcellpos(list(i)); end cells2add = CELLIDLIST(pos); % add cellid and value for each new cell nws = length(cells2add); vardata(lastcellpos+1:lastcellpos+nws,1)=cells2add'; vardata(lastcellpos+1:lastcellpos+nws,prp+1)={value}; %#ok lastcellpos = lastcellpos + nws; end end end % Time stamp timestamp = {gettimestamp}; % Insert data % Find the position to insert to NumCol = length(propnames); NumCell = size(vardata,1); NumAnal = length(ANALYSES); %#ok if NumAnal == 0 lastcolumn = 0; else lastcolumn = ANALYSES(NumAnal).columns(end); end columns = lastcolumn+1:lastcolumn+NumCol; isoverwrite = false; % changed later if previous data is overwritten % Add to ANALYSES switch pora case 'p' % properties are added one by one for i = 1:NumCol [prevanal anum] = findanalysis(propnames{i}); if prevanal % give an option to overwrite str = sprintf('\nINSERTDATA: Analysis already exists for %s at position %d.',propnames{i},prevanal); disp(str) co = input('Overwrite previous data? overwrite/cancel [c] ','s'); if ~strncmp(co,'overwrite',4) fprintf('\n%s\n','INSERTDATA: Action cancelled. No data inserted.') return end columns(i) = prevanal; ANALYSES(anum(1)).timestamp = timestamp; %#ok ANALYSES(anum(1)).varargin = arglist; %#ok else ANALYSES(NumAnal+i).funhandle = funhandle; %#ok ANALYSES(NumAnal+i).varargin = arglist; %#ok ANALYSES(NumAnal+i).propnames = propnames(i); %#ok ANALYSES(NumAnal+i).columns = columns(i); %#ok ANALYSES(NumAnal+i).timestamp = timestamp; %#ok end end case 'a' % output arguments of an analysis are added as a single entry [cols anum] = findanalysis(funhandle); mts = length(anum); % multiple matches with different arguments are possible isfound = nan(1:mts); for aa = 1:mts isfound(aa) = ~isequal(cols,0) & isequal(ANALYSES(anum(aa)).varargin,arglist)... & isequal(ANALYSES(anum(aa)).propnames,propnames); % consider the same if the analysis name, input and output parameters are the same end if any(isfound) % give an option to overwrite anum = anum(logical(isfound)); columns = ANALYSES(anum).columns; str = sprintf('\nINSERTDATA: Analysis already exists at position %d.',cols); disp(str) co = input('Overwrite previous data? overwrite/cancel [c] ','s'); if ~strncmp(co,'overwrite',4) fprintf('\n%s\n','INSERTDATA: Action cancelled. No data inserted.') return else isoverwrite = true; end ANALYSES(anum).timestamp = timestamp; else ANALYSES(NumAnal+1).funhandle = funhandle; ANALYSES(NumAnal+1).varargin = arglist; ANALYSES(NumAnal+1).propnames = propnames; ANALYSES(NumAnal+1).columns = columns; ANALYSES(NumAnal+1).timestamp = timestamp; end end % Add to TheMatrix [cmn inxa inxb] = intersect(CELLIDLIST,vardata(:,1)); %#ok<*ASGLU> if iscell(TheMatrix) %#ok TheMatrix(inxa,columns) = vardata(inxb,2:end); % TheMatrix is a cell in the updated CellBase else if ~isoverwrite TheMatrix(:,columns) = NaN; % initialize with NaNs to avoid padding with zeros end TheMatrix(inxa,columns) = cell2mat(vardata(inxb,2:end)); % keep it compatible with the old version end notfound_list = setdiff(vardata(:,1),CELLIDLIST); NotFound = length(notfound_list); % Return changed variables to workspace & save all assignin('base','TheMatrix',TheMatrix) assignin('base','ANALYSES',ANALYSES) cb = getpref('cellbase','fname'); [pth fnm ext] = fileparts(cb); dsr = datestr(now); dsr = regexprep(dsr,':','_'); backup_name = fullfile(pth,[fnm '_' dsr ext]); copyfile(cb,backup_name) % make backup before overwriting save(cb,'TheMatrix','ANALYSES','CELLIDLIST') % Feedback if NotFound donestr = sprintf('INSERTDATA done.\nData added to %d cells creating/updating %d properti(es).\n %d cellids not found.\n',NumCell,NumCol,NotFound); else donestr = sprintf('INSERTDATA done.\nData added to %d cells creating/updating %d properti(es).\n',NumCell,NumCol); end disp(donestr); if nargout > 0 varargout{1} = notfound_list; end % ------------------------------------------------------------------------- function value = prompt_for_value(tag,varargin) value = []; question = sprintf('Enter value for %s ',tag); if nargin == 1 while isempty(value) value = input(question); end elseif strcmpi(varargin{1},'NaN') value = input(question); if isempty(value) value = NaN; end end % ------------------------------------------------------------------------- function ts = gettimestamp % Now c = clock; ts = sprintf('%d/%d/%d %.2d:%.2d',c(2),c(3),c(1),c(4),c(5)); % ------------------------------------------------------------------------- function vardata = read_data(fullpth) % Decompose path name [pth fnm ext] = fileparts(fullpth); % Read the data for supported formats switch ext case {'.xls' '.xlsx'} [t0 t1 vardata] = xlsread(fullpth); % Excel case '.mat' pvd = load(fullpth); % Matlab fld = fieldnames(pvd); vardata = pvd.(fld{1}); otherwise vardata = []; end \ No newline at end of file +function varargout = insertdata(varargin) %INSERTDATA Insert data into CellBase directly. % NF = INSERTDATA(DATA,PARAM,VALUE) inserts DATA into TheMatrix % and ANALYSES (see CellBase documentation). It optionally returns the % list of entries in DATA which did not provide a match with CELLIDLIST % (NF). % Input arguments: % DATA - Either a Matlab variable or a full pathname to a .mat or an % Excel file. It can optionally contain a header row with % 'property_names' in the first column and corresponding property % names for data columns. First column should contain cellIDs. If % property names are added as both input argument and data % header, the user is forced to choose which one to use. % 'TYPE', T - Parameter indicating whether an analysis or a set of % properties are added. T should start with the letter 'a' or 'p' % accordingly. % 'NAME', NM - Name of the analysis or properti(es). For analysis: % it should be the name of a valid m file. For properties: either % a character array (one property) or a cell array of strings % (multiple properties). % 'INPUT_ARGUMENTS', LS1 - Input arguments for analysis, cell array. % 'OUTPUT_ARGUMENTS', LS2 - Names of output arguments for analysis, % cell array of strings. This determines the property names when % an analysis is added. % % The number of properties or output arguments (in case of adding values % to an analysis) must match the number of data columns (number of all % columns minus one) in DATA. % % Missing input arguments are asked for interactively. If DATA is empty, % the user has to browse for the data file. If 'Cancel' is selected for % browsing result, data values will interactively be prompted for % according to a selected tag type (animal, session, tetrode or cell). % % If a property or an analysis is already added to CellBase, the user is % asked whether to overwrite previous data. An analysis is only % considered the same if the name of the m file and both the list of % input and output arguments are the same. If the data is overwritten, % the timestamp property in ANALYSES is updated. % % New data is inserted into TheMatrix and ANALYSES according to the % corresponding cellIDs. A backup of the previous cellbase file is stored % before overwriting. % % Examples: % insertdata(data,'type','analysis','name','LRatio','input_arguments',... % {{'Amplitude','Energy'}},'output_arguments',{'ID_amp','Lr_amp'}) % not_found = insertdata([],'type','prop','name','validity'); % insertdata('c:\Balazs\_analysis\NB\tagging\validity.xls','type',... % 'prop','name','validity') % insertdata('c:\Balazs\_analysis\NB\tagging2\spikeshapecorr.xls','type',... % 'analysis','name','spikeshapecorr') % % See also ADDANALYSIS and RUNANALYSIS. % Edit log: AK,SPR 5/10; BH 5/3/12, TO 5/2018 % Input arguments prs = inputParser; addOptional(prs,'data',[],@(s)isempty(s)||iscell(s)||ischar(s)) addParamValue(prs,'type','',@(s)ismember(s(1),{'p','a'})) % property or analysis addParamValue(prs,'name',{},@(s)ischar(s)||iscell(s)) % name of properties or analysis function addParamValue(prs,'input_arguments',{},@iscell) % name of input arguments for analysis function addParamValue(prs,'output_arguments',{},@(s)ischar(s)||iscell(s)) % name of output arguments for analysis function - used for proporty names if type=analysis parse(prs,varargin{:}) g = prs.Results; % If no options specified, ask everything % Property or analysis? if isempty(g.type) pora = ''; while ~ismember(pora,{'p','a'}) pora = input('\n Do you want to insert a property or an analysis? p/a ','s'); end else pora = g.type(1); end % Property names or mfile name switch pora case 'p' % property names if isempty(g.name) tinp = input('\n Please enter the property names you want to add. ','s'); propnames = strread(tinp,'%s','delimiter',', ')'; else propnames = g.name; end if ischar(propnames) % convert to cell if there's only one property propnames = {propnames}; end funhandle = @insertdata; % for properties, the function handle is 'insertdata' arglist = {}; % a property does not have arguments % (except for manually entered properties, where it is the 'option', see below) case 'a' % mfile name if isempty(g.name) wi = 0; while ~wi mfile = input('\n Please enter the name of the analysis function. ','s'); funhandle = str2func(mfile); % check analysis function funinfo = functions(funhandle); if ~isempty(funinfo.file) fprintf('\n%s\n','Analysis file was loacated: ') disp(funinfo.file) wi = 1; else fprintf('\n%s\n','INSERTDATA: Function is not valid.') end end else mfile = g.name; funhandle = str2func(mfile); end if isempty(g.input_arguments) % mfile input arguments tinp = input(['\n Please enter the list of input arguments for '... mfile ',\n or press Enter for no arguments. ']); arglist = tinp; else arglist = g.input_arguments; end if isempty(g.output_arguments) % mfile output arguments (properties) tinp = input(['\n Please enter the list of output arguments for '... mfile '. '],'s'); propnames = strread(tinp,'%s','delimiter',', ')'; else propnames = g.output_arguments; end if ischar(propnames) % convert to cell if there's only one output argument propnames = {propnames}; end end % Load data if isempty(g.data) [filename, pathname] = uigetfile( ... {'*.mat;*.xls;*.xlsx','Supported formats (*.mat,*.xls,*.xlsx)';... '*.mat','MAT-files (*.mat)'; ... '*.xls;*.xlsx','Excel files (*.xls,*.xlsx)'; ... '*.*', 'All Files (*.*)'}, ... 'Select Datafile'); % select data file fullpth = fullfile(pathname,filename); vardata = read_data(fullpth); else if ischar(g.data) vardata = read_data(g.data); else vardata = g.data; end end % Load CellBase load(getpref('cellbase','fname')); % Check data if ~isempty(vardata) if isequal(vardata{1,1},'property_names') % property names in data header newpropnames = vardata(1,2:end); vardata = vardata(2:end,:); if isempty(propnames) propnames = newpropnames; fprintf('\n%s','Using property names detected in data header:') disp(propnames) end if ~isequal(propnames,newpropnames) % optionally overwrite input argument with header useheader = input('\nUse property/argument names of data header? (y/n) ','s'); while ~ismember(useheader,{'y','n'}) useheader = input('\nUse property/argument names of data header? (y/n) ','s'); end if isequal(useheader,'y') propnames = newpropnames; fprintf('\n%s','Using property names detected in data header:') disp(propnames) end end end infinx = cellfun(@(s)isequal('Inf',s),vardata); % convert 'Inf' to Inf vardata(infinx) = {Inf}; infinx = cellfun(@(s)isequal('-Inf',s),vardata); vardata(infinx) = {-Inf}; naninx = cellfun(@(s)isequal('NaN',s),vardata); % convert 'NaN' to NaN vardata(naninx) = {NaN}; if ~isequal(length(propnames),size(vardata,2)-1) error('INSERTDATA: Data does not match the number of properties.') end end % If no data, add values one by one if isempty(vardata) option = input(['\nYou will be prompted to add values manually. \n'... 'Would you like to add separate value for each \n'... 'animal/session/tetrode/cell? '],'s'); if ~(strncmp(option,'ani',3) || strncmp(option,'rat',3) || ... strncmp(option,'ses',3) || strncmp(option,'tet',3) || ... strncmp(option,'cel',3)) error('INSERTDATA: unknown option.'); else arglist = {option}; % store the chosen option in the argument field end % Add values for each properties vardata = {}; % initalize for prp = 1:length(propnames) propname = propnames{prp}; lastcellpos = 0; % Create list to display list = listtag(option); % find all relevant cell classes if strncmp(option,'session',3) list2add = strcat(char(list(:,1)),'_',char(list(:,2))); elseif strncmp(option,'tetrode',3) list2add = strcat(char(list(:,1)),'_',char(list(:,2)),'_',char(list(:,3))); else % option = rat or cell list2add = char(list); end % Type values fprintf('\n%s%s%s\n','Insert values for ',propname,'.') for i = 1:size(list2add,1) value = prompt_for_value(list2add(i,:)); if strncmp(option,'session',3) pos = findcellpos('rat',list(i,1),'session',list(i,2)); elseif strncmp(option,'tetrode',3) pos = findcellpos('rat',list(i,1),'session',list(i,2),'tetrode',list(i,3)); elseif strncmp(option,'rat',3) pos = findcellpos('rat',list(i)); elseif strncmp(option,'animal',3) pos = findcellpos('animal',list(i)); else pos = findcellpos(list(i)); end cells2add = CELLIDLIST(pos); % add cellid and value for each new cell nws = length(cells2add); vardata(lastcellpos+1:lastcellpos+nws,1)=cells2add'; vardata(lastcellpos+1:lastcellpos+nws,prp+1)={value}; %#ok lastcellpos = lastcellpos + nws; end end end % Time stamp timestamp = {gettimestamp}; % Insert data % Find the position to insert to NumCol = length(propnames); NumCell = size(vardata,1); NumAnal = length(ANALYSES); %#ok if NumAnal == 0 lastcolumn = 0; else lastcolumn = ANALYSES(NumAnal).columns(end); end columns = lastcolumn+1:lastcolumn+NumCol; isoverwrite = false; % changed later if previous data is overwritten % Add to ANALYSES switch pora case 'p' % properties are added one by one for i = 1:NumCol [prevanal anum] = findanalysis(propnames{i}); if prevanal % give an option to overwrite str = sprintf('\nINSERTDATA: Analysis already exists for %s at position %d.',propnames{i},prevanal); disp(str) co = input('Overwrite previous data? overwrite/cancel [c] ','s'); if ~strncmp(co,'overwrite',4) fprintf('\n%s\n','INSERTDATA: Action cancelled. No data inserted.') return end columns(i) = prevanal; ANALYSES(anum(1)).timestamp = timestamp; %#ok ANALYSES(anum(1)).varargin = arglist; %#ok else ANALYSES(NumAnal+i).funhandle = funhandle; %#ok ANALYSES(NumAnal+i).varargin = arglist; %#ok ANALYSES(NumAnal+i).propnames = propnames(i); %#ok ANALYSES(NumAnal+i).columns = columns(i); %#ok ANALYSES(NumAnal+i).timestamp = timestamp; %#ok end end case 'a' % output arguments of an analysis are added as a single entry [cols anum] = findanalysis(funhandle); mts = length(anum); % multiple matches with different arguments are possible isfound = nan(1:mts); for aa = 1:mts isfound(aa) = ~isequal(cols,0) & isequal(ANALYSES(anum(aa)).varargin,arglist)... & isequal(ANALYSES(anum(aa)).propnames,propnames); % consider the same if the analysis name, input and output parameters are the same end if any(isfound) % give an option to overwrite anum = anum(logical(isfound)); columns = ANALYSES(anum).columns; str = sprintf('\nINSERTDATA: Analysis already exists at position %d.',cols); disp(str) co = input('Overwrite previous data? overwrite/cancel [c] ','s'); if ~strncmp(co,'overwrite',4) fprintf('\n%s\n','INSERTDATA: Action cancelled. No data inserted.') return else isoverwrite = true; end ANALYSES(anum).timestamp = timestamp; else ANALYSES(NumAnal+1).funhandle = funhandle; ANALYSES(NumAnal+1).varargin = arglist; ANALYSES(NumAnal+1).propnames = propnames; ANALYSES(NumAnal+1).columns = columns; ANALYSES(NumAnal+1).timestamp = timestamp; end end % Add to TheMatrix [cmn inxa inxb] = intersect(CELLIDLIST,vardata(:,1)); %#ok<*ASGLU> if iscell(TheMatrix) %#ok TheMatrix(inxa,columns) = vardata(inxb,2:end); % TheMatrix is a cell in the updated CellBase else if ~isoverwrite TheMatrix(:,columns) = NaN; % initialize with NaNs to avoid padding with zeros end TheMatrix(inxa,columns) = cell2mat(vardata(inxb,2:end)); % keep it compatible with the old version end notfound_list = setdiff(vardata(:,1),CELLIDLIST); NotFound = length(notfound_list); % Return changed variables to workspace & save all assignin('base','TheMatrix',TheMatrix) assignin('base','ANALYSES',ANALYSES) cb = getpref('cellbase','fname'); [pth fnm ext] = fileparts(cb); dsr = datestr(now); dsr = regexprep(dsr,':','_'); backup_name = fullfile(pth,[fnm '_' dsr ext]); copyfile(cb,backup_name) % make backup before overwriting save(cb,'TheMatrix','ANALYSES','CELLIDLIST','PREFERENCES') % Feedback if NotFound donestr = sprintf('INSERTDATA done.\nData added to %d cells creating/updating %d properti(es).\n %d cellids not found.\n',NumCell,NumCol,NotFound); else donestr = sprintf('INSERTDATA done.\nData added to %d cells creating/updating %d properti(es).\n',NumCell,NumCol); end disp(donestr); if nargout > 0 varargout{1} = notfound_list; end % ------------------------------------------------------------------------- function value = prompt_for_value(tag,varargin) value = []; question = sprintf('Enter value for %s ',tag); if nargin == 1 while isempty(value) value = input(question); end elseif strcmpi(varargin{1},'NaN') value = input(question); if isempty(value) value = NaN; end end % ------------------------------------------------------------------------- function ts = gettimestamp % Now c = clock; ts = sprintf('%d/%d/%d %.2d:%.2d',c(2),c(3),c(1),c(4),c(5)); % ------------------------------------------------------------------------- function vardata = read_data(fullpth) % Decompose path name [pth fnm ext] = fileparts(fullpth); % Read the data for supported formats switch ext case {'.xls' '.xlsx'} [t0 t1 vardata] = xlsread(fullpth); % Excel case '.mat' pvd = load(fullpth); % Matlab fld = fieldnames(pvd); vardata = pvd.(fld{1}); otherwise vardata = []; end \ No newline at end of file diff --git a/CellBase_R2013a/Functions/database_functions/analyses/setvalue.m b/CellBase_R2013a/Functions/database_functions/analyses/setvalue.m index 4c45189..c230e71 100644 --- a/CellBase_R2013a/Functions/database_functions/analyses/setvalue.m +++ b/CellBase_R2013a/Functions/database_functions/analyses/setvalue.m @@ -6,7 +6,7 @@ % % See also GETVALUE. -% Edit log: BH 4/16/2013 +% Edit log: BH 4/16/2013, TO 5/2018 % Load CellBase load(getpref('cellbase','fname')); @@ -37,7 +37,7 @@ dsr = regexprep(dsr,':','_'); backup_name = fullfile(pth,[fnm '_' dsr ext]); copyfile(cb,backup_name) % make backup before overwriting -save(cb,'TheMatrix','ANALYSES','CELLIDLIST') +save(cb,'TheMatrix','ANALYSES','CELLIDLIST','PREFERENCES') % Feedback status = true; \ No newline at end of file diff --git a/CellBase_R2013a/Functions/database_functions/cellbase/default_preferences.m b/CellBase_R2013a/Functions/database_functions/cellbase/default_preferences.m new file mode 100644 index 0000000..5b3ca57 --- /dev/null +++ b/CellBase_R2013a/Functions/database_functions/cellbase/default_preferences.m @@ -0,0 +1,33 @@ +function PREFERENCES = default_preferences() +% DEFAULT_PREFERENCES creates a struct PREFERENCES containing default +% parameters specific to a cellbase. Note than cellbase-general preferences +% (cellbase name, data folder, cellbase file) are manipulated with +% getpref('cellbase')/setpref('cellbase',...). +% +% See also import_preferences(), setcbpref(name,value), getcbpref(name), initcb() +% +% TO 05/2018 + +cb_path = which('initcb'); +cb_path=fileparts(fileparts(fileparts(fileparts(cb_path)))); + +PREFERENCES = struct(); + +%TrialEvents parameters +PREFERENCES.TrialEvents_fname = 'TrialEvents.mat'; +PREFERENCES.TrialEvents_fun = fullfile(cb_path,'Templates','MakeTrialEvents.m'); +PREFERENCES.TrialEvents_defineEventEpochs = fullfile(cb_path,'Templates','defineEventEpochs.m'); + +%StimEvents parameters +PREFERENCES.StimEvents_fname = 'StimEvents.mat'; +PREFERENCES.StimEvents_fun = fullfile(cb_path,'Templates','MakeStimEvents.m'); + +%Spike times parameters +PREFERENCES.Spikes_cell_pattern = 'TT'; +PREFERENCES.Spikes_timefactor = 1; +PREFERENCES.Spikes_create_fun = ''; + +%Database parameters +PREFERENCES.session_separator = ''; + + diff --git a/CellBase_R2013a/Functions/database_functions/cellbase/getcbpref.m b/CellBase_R2013a/Functions/database_functions/cellbase/getcbpref.m new file mode 100644 index 0000000..a89f887 --- /dev/null +++ b/CellBase_R2013a/Functions/database_functions/cellbase/getcbpref.m @@ -0,0 +1,40 @@ +function val = getcbpref(name) +% GETCBPREF() returns current cellbase's preference value for preference name STR. +% Cellbase-specific preferences are stored in cellbase file +% (getpref('cellbase','fname')). Note than cellbase-general preferences +% (cellbase name, data folder, cellbase file) are manipulated with +% getpref('cellbase')/setpref('cellbase',...). +% +% Returns VAL, the value of preference NAME. Returns FALSE if n preference +% with NAME exists. +% +% See also: setcbpref(name,value), default_preferences() +% +% TO 05/2018 + +if any(strcmp({'datapath','name','fname','filesep','cellbases'},name)) %global settings + warning('Please use getpref to get global cellbase settings.'); + val = getpref('cellbase',name); +else %correct use for cellbase-specific parameters + if exist(fullfile(getpref('cellbase','fname')),'file')==2 + P = load(fullfile(getpref('cellbase','fname')),'PREFERENCES'); + fields = fieldnames(P); + if ~isempty(fields) + P=P.PREFERENCES; + if isfield(P,name) + val=P.(name); + else %no parameter in PREFERENCES with that name + val = false; + warning('getcbpref: no parameter with the specified name found. Try setcbpref() first.'); + end + else %no preference file + import_preferences(); + val=getcbpref(name); + end + + else %no cellbase + error('getcbpref: No Cellbase database found. Check cellbase filename.'); + end +end + +end \ No newline at end of file diff --git a/CellBase_R2013a/Functions/database_functions/cellbase/import_preferences.m b/CellBase_R2013a/Functions/database_functions/cellbase/import_preferences.m new file mode 100644 index 0000000..2f08abc --- /dev/null +++ b/CellBase_R2013a/Functions/database_functions/cellbase/import_preferences.m @@ -0,0 +1,30 @@ +function import_preferences() +% IMPORT_PREFERENCES creates a struct PREFERENCES containing default parameters +% or loads preferences from getpref('cellbase'). This is a +% convenience function to maintain backwards compatibility to cellbase +% 5fbf007 (12 Sep 2017) and prior. + +% See also default_preferences(), setcbpref(name,value), getcbpref(name), initcb() +% +% TO 05/2018 + +str = 'No PREFERENCE variable found. Likely due to use of older cellbase version. Please choose if you want to use default parameters or import from getpref("cellbase"). '; +str=strcat(str,'Preferences can be manipulated using getpref and setpref and are stored in your cellbase file.'); + +A = questdlg(str,'convert_preferences','Default','Import','Default'); + +PREFERENCES = default_preferences(); + +switch A + case 'Default' + % + case 'Import' + PREFERENCES.TrialEvents_fname = getpref('cellbase','TrialEvents_filename'); + PREFERENCES.StimEvents_fname = getpref('cellbase','StimEvents_filename'); + PREFERENCES.Spikes_cell_pattern = getpref('cellbase','cell_pattern'); + PREFERENCES.Spikes_timefactor = getpref('cellbase','timefactor'); +end + +CB = load(fullfile(getpref('cellbase','fname'))); +CB.PREFERENCES=PREFERENCES; +save(fullfile(getpref('cellbase','fname')),'-struct','CB') diff --git a/CellBase_R2013a/Functions/database_functions/cellbase/initcb.m b/CellBase_R2013a/Functions/database_functions/cellbase/initcb.m index 2698b33..00c0cea 100644 --- a/CellBase_R2013a/Functions/database_functions/cellbase/initcb.m +++ b/CellBase_R2013a/Functions/database_functions/cellbase/initcb.m @@ -9,7 +9,8 @@ function initcb(cb_name) % % See also LOADCB, CHOOSECB, DELETECB and ADDNEWCELLS. -% Edit log: AK 3/04, 10/06; BH 3/18/11, 5/30/11, 4/26/12, 5/7/12, 8/20/13 +% Edit log: AK 3/04, 10/06; BH 3/18/11, 5/30/11, 4/26/12, 5/7/12, +% 8/20/13, TO 5/2018 % Check input arguments error(nargchk(0,1,nargin)) @@ -51,24 +52,23 @@ function initcb(cb_name) disp(['File name is ' fname]) disp(['CellBase name is ' cb_name]) +% cellbase-specific preferences + % Timestamp conversion tsc = questdlg('I''m going convert timestamps to seconds in','Timestamp conversion',... - 'CellBase','MClust','CellBase'); + 'CellBase (factor=10^-4)','MClust (factor=1)','CellBase (factor=10^-4)'); switch tsc - case 'CellBase' + case 'CellBase (factor=10^-4)' timefactor = 1e-4; % TT*.mat files will reflect the timestamps of the Ntt files; % loadcb will convert them to seconds - case 'MClust' + case 'MClust (factor=1)' timefactor = 1; % timestamps in TT*.mat files will already be converted to seconds end % Set other preferences (persistent and maintain their values between MATLAB sessions) -setpref('cellbase','session_filename','TrialEvents.mat'); -setpref('cellbase','TrialEvents_filename','TrialEvents.mat'); -setpref('cellbase','StimEvents_filename','StimEvents.mat'); -setpref('cellbase','cell_pattern','TT'); -setpref('cellbase','filesep',filesep); -setpref('cellbase','timefactor',timefactor); + +PREFERENCES = default_preferences(); +PREFERENCES.Spikes_timefactor=timefactor; % Store cellbases to allow multiple instances if ispref('cellbase','cellbases') @@ -82,18 +82,19 @@ function initcb(cb_name) end cellbases{end+1} = gp; setpref('cellbase','cellbases',cellbases) +setpref('cellbase','filesep',filesep); % Open main database file QuestionStr = sprintf('\n %s already exists. \n\n Do you want to delete it? \n',fname); -fid = fopen(fname); -if ( fid == -1) || strcmp(questdlg(QuestionStr,... + +if exist(fname,'file')~=2 || strcmp(questdlg(QuestionStr,... 'InitCB','Yes','No','No'),'Yes') %file doesn't exist or to be deleted ! % Save empty CellBase TheMatrix = []; ANALYSES = []; CELLIDLIST = []; - save(fname,'TheMatrix','ANALYSES','CELLIDLIST'); + save(fname,'TheMatrix','ANALYSES','CELLIDLIST','PREFERENCES'); % Convert TrialEvents & Sessions NUM_CELLS = addnewcells; @@ -112,7 +113,6 @@ function initcb(cb_name) warndlg('Something went wrong.','InitCB'); end else - fclose(fid); welcomestr = sprintf('\n %s already exists. Delete it if you need a rebuild.\n',fname); msgbox(welcomestr,'Welcome to CellBase','warn'); end \ No newline at end of file diff --git a/CellBase_R2013a/Functions/database_functions/cellbase/loadcb.m b/CellBase_R2013a/Functions/database_functions/cellbase/loadcb.m index 6b51e89..4c3e434 100644 --- a/CellBase_R2013a/Functions/database_functions/cellbase/loadcb.m +++ b/CellBase_R2013a/Functions/database_functions/cellbase/loadcb.m @@ -1,6 +1,6 @@ function varargout = loadcb(varargin) %LOADCB Load the CellBase files. -% LOADCB loads CellBase (CELLIDLIST, ANALYSES, TheMatrix) into the caller +% LOADCB loads CellBase (CELLIDLIST, ANALYSES, TheMatrix, PREFERENCES) into the caller % function's workspace. % % OUT = LOADCB(CELLID,FILETYPE) loads the specified file (FILETYPE) of @@ -10,7 +10,7 @@ % % See also INITCB and CELLID2FNAMES. -% Edit log: AK 3/04, 11/06, 4/10; BH 7/6/12 +% Edit log: AK 3/04, 11/06, 4/10; BH 7/6/12, TO 5/2018 % Without input arguments, load the entire database if nargin == 0 @@ -33,7 +33,7 @@ % Filename to load fname = cellid2fnames(cellid,filetype); - TIMEFACTOR = getpref('cellbase','timefactor'); % scaling factor to convert spike times into seconds + TIMEFACTOR = getcbpref('Spikes_timefactor'); % scaling factor to convert spike times into seconds if nargout == 1 % if we are loading into a variable if strncmpi(filetype,'Spikes',5) @@ -44,7 +44,7 @@ % Load waveform data (Ntt file) Nttfile = cellid2fnames(cellid,'ntt'); - TIMEFACTOR = getpref('cellbase','timefactor'); % scaling factor to convert spike times into seconds + TIMEFACTOR = getcbpref('Spikes_timefactor'); % scaling factor to convert spike times into seconds [all_spikes all_waves] = LoadTT_NeuralynxNT(Nttfile); [junk junk2 evoked_inx] = intersect(SpikeTimes,all_spikes*TIMEFACTOR); if ~isequal(junk,SpikeTimes) % internal check for spike times diff --git a/CellBase_R2013a/Functions/database_functions/cellbase/mountcb.m b/CellBase_R2013a/Functions/database_functions/cellbase/mountcb.m index 9b1f53b..00c44bf 100644 --- a/CellBase_R2013a/Functions/database_functions/cellbase/mountcb.m +++ b/CellBase_R2013a/Functions/database_functions/cellbase/mountcb.m @@ -9,7 +9,7 @@ function mountcb(cb_name) % % See also INITCB, LOADCB, CHOOSECB and DELETECB. -% Edit log: TL 10/21/2015 +% Edit log: TL 10/21/2015, TO 5/2018 % Check input arguments narginchk(0,1) @@ -48,13 +48,7 @@ function mountcb(cb_name) timefactor = 1; % timestamps in TT*.mat files will already be converted to seconds end -% Set other preferences (persistent and maintain their values between MATLAB sessions) -setpref('cellbase','session_filename','TrialEvents.mat'); -setpref('cellbase','TrialEvents_filename','TrialEvents.mat'); -setpref('cellbase','StimEvents_filename','StimEvents.mat'); -setpref('cellbase','cell_pattern','TT'); -setpref('cellbase','filesep',filesep); -setpref('cellbase','timefactor',timefactor); + % Store cellbases to allow multiple instances if ispref('cellbase','cellbases') @@ -68,6 +62,10 @@ function mountcb(cb_name) end cellbases{end+1} = gp; % adds the new CellBase to 'cellbases' setpref('cellbase','cellbases',cellbases) +setpref('cellbase','filesep',filesep); + +%other preferences should be present in cellbase or will be queried when +%required (TO 5/2018) % Feedback welcomestr = sprintf('New CellBase named %s was successfully mounted.\n',cb_name); diff --git a/CellBase_R2013a/Functions/database_functions/cellbase/setcbpref.m b/CellBase_R2013a/Functions/database_functions/cellbase/setcbpref.m new file mode 100644 index 0000000..ad4f47e --- /dev/null +++ b/CellBase_R2013a/Functions/database_functions/cellbase/setcbpref.m @@ -0,0 +1,31 @@ +function setcbpref(name,val) +% SETCBPREF() sets current cellbase's preference value for preference NAME +% to VAL. +% Cellbase-specific preferences are stored in cellbase file +% (getpref('cellbase','fname')). Note than cellbase-general preferences +% (cellbase name, data folder, cellbase file) are manipulated with +% getpref('cellbase')/setpref('cellbase',...). +% +% See also: getcbpref(name), default_preferences() +% +% TO 05/2018 + +if any(strcmp({'datapath','name','fname','filesep','cellbases'},name)) %global settings + warning('Please use setpref to set global cellbase settings.'); + setpref('cellbase',name,val); +else %correct use for cellbase-specific parameters + if exist(fullfile(getpref('cellbase','fname')),'file')==2 + CB = load(fullfile(getpref('cellbase','fname'))); + fields = fieldnames(CB); + if ~isempty(fields) + CB.PREFERENCES.(name)=val; + save(fullfile(getpref('cellbase','fname')),'-struct','CB') + else %no preference file + import_preferences(); + setcbpref(name,val); + end + + else %no cellbase + error('setcbpref: No Cellbase database found. Check cellbase filename.'); + end +end \ No newline at end of file diff --git a/CellBase_R2013a/Functions/database_functions/cellbase/upgradecb.m b/CellBase_R2013a/Functions/database_functions/cellbase/upgradecb.m index 7c4ba0c..b51aa81 100644 --- a/CellBase_R2013a/Functions/database_functions/cellbase/upgradecb.m +++ b/CellBase_R2013a/Functions/database_functions/cellbase/upgradecb.m @@ -35,6 +35,9 @@ cellbases{end+1} = gp; % Set preferences (persistent and maintain their values between MATLAB sessions) -setpref('cellbase','timefactor',timefactor); +% globale preferences setpref('cellbase','cellbases',cellbases); -setpref('cellbase','name',cb_name); \ No newline at end of file +setpref('cellbase','name',cb_name); + +%cellbase specific preferences +setcbpref('cellbase','timefactor',timefactor); \ No newline at end of file diff --git a/CellBase_R2013a/Functions/database_functions/cells/addcell.m b/CellBase_R2013a/Functions/database_functions/cells/addcell.m index ef852a1..d18233d 100644 --- a/CellBase_R2013a/Functions/database_functions/cells/addcell.m +++ b/CellBase_R2013a/Functions/database_functions/cells/addcell.m @@ -28,7 +28,7 @@ end % Load cellbase -clear global CELLIDLIST ANALYSES TheMatrix +clear global CELLIDLIST ANALYSES TheMatrix PREFERENCES cellbase_fname = getpref('cellbase','fname'); load(cellbase_fname); @@ -115,5 +115,5 @@ % Save cellbase assignin('base','TheMatrix',TheMatrix) assignin('base','CELLIDLIST',CELLIDLIST) -save(cellbase_fname,'TheMatrix','ANALYSES','CELLIDLIST') +save(cellbase_fname,'TheMatrix','ANALYSES','CELLIDLIST','PREFERENCES') OK = 1; \ No newline at end of file diff --git a/CellBase_R2013a/Functions/database_functions/cells/addnewcells.m b/CellBase_R2013a/Functions/database_functions/cells/addnewcells.m index bbfcf53..0ef3c7b 100644 --- a/CellBase_R2013a/Functions/database_functions/cells/addnewcells.m +++ b/CellBase_R2013a/Functions/database_functions/cells/addnewcells.m @@ -26,7 +26,7 @@ g = prs.Results; % Get CellBase preferences -clear global CELLIDLIST ANALYSES TheMatrix % refresh the globals +clear global CELLIDLIST ANALYSES TheMatrix PREFERENCES % refresh the globals cellbase_datapath = getpref('cellbase','datapath'); % Find all cells and sort the new ones diff --git a/CellBase_R2013a/Functions/database_functions/cells/delcell.m b/CellBase_R2013a/Functions/database_functions/cells/delcell.m index 016bc8a..8662f81 100644 --- a/CellBase_R2013a/Functions/database_functions/cells/delcell.m +++ b/CellBase_R2013a/Functions/database_functions/cells/delcell.m @@ -7,7 +7,7 @@ function delcell(cellid) % % See also ADDCELL, INSERTDATA and DELANALYSIS. -% Edit log: BH 6/7/12 +% Edit log: BH 6/7/12, TO 5/2018 % Load CellBase load(getpref('cellbase','fname')); @@ -45,7 +45,7 @@ function delcell(cellid) dsr = regexprep(dsr,':','_'); backup_name = fullfile(pth,[fnm '_' dsr ext]); copyfile(cb,backup_name) % make backup before overwriting -save(cb,'TheMatrix','ANALYSES','CELLIDLIST'); +save(cb,'TheMatrix','ANALYSES','CELLIDLIST','PREFERENCES'); % Feedback if ischar(cellid) diff --git a/CellBase_R2013a/Functions/database_functions/cells/findallcells.m b/CellBase_R2013a/Functions/database_functions/cells/findallcells.m index 1781856..2a35594 100644 --- a/CellBase_R2013a/Functions/database_functions/cells/findallcells.m +++ b/CellBase_R2013a/Functions/database_functions/cells/findallcells.m @@ -7,7 +7,7 @@ % % See also FINDCELLPOS. -% Edit log: AK 3/04; ZFM 7/05; BH 3/21/11, 4/23/13 +% Edit log: AK 3/04; ZFM 7/05; BH 3/21/11, 4/23/13, TO 05/2018 % Get cellbase preferences cellbase_datapath = getpref('cellbase','datapath'); @@ -40,11 +40,11 @@ % Added options for specifying an cut directory below the session % directory - if ispref('cellbase','group') - cell_pattern = getpref('cellbase','cell_pattern'); + if getcbpref('group') + cell_pattern = getcbpref('Spikes_cell_pattern'); % Deal with hierarchy of cut directories - cut_dirs = getpref('cellbase','group'); + cut_dirs = getcbpref('cellbase','group'); if iscell(cut_dirs) % there is more than one cut directory specified, % return the first existing directory (ie cut directories are in order of diff --git a/CellBase_R2013a/Functions/database_functions/conversion/cellid2fnames.m b/CellBase_R2013a/Functions/database_functions/conversion/cellid2fnames.m index 73347c1..7d5b5d2 100644 --- a/CellBase_R2013a/Functions/database_functions/conversion/cellid2fnames.m +++ b/CellBase_R2013a/Functions/database_functions/conversion/cellid2fnames.m @@ -29,16 +29,16 @@ % % See also CELLID2TAGS. -% Edit log: ZFM 10/7/04, AK 11/06, AK 4/10, SPR 07/2010, BH 6/23/11 +% Edit log: ZFM 10/7/04, AK 11/06, AK 4/10, SPR 07/2010, BH 6/23/11, TO 5/2018 -% Get CellBase preferences +% get cellbase global preferences cellbase_datapath = getpref('cellbase','datapath'); -session_fname = getpref('cellbase','session_filename'); sep = getpref('cellbase','session_separator'); -if ispref('cellbase','StimEvents_filename') - stim_fname = getpref('cellbase','StimEvents_filename'); -end -cellbase_cell_pattern = getpref('cellbase','cell_pattern'); + +% get cellbase specific preferences +TrialEvents_fname = getcbpref('TrialEvents_fname'); +StimEvents_fname = getcbpref('StimEvents_fname'); +cellbase_cell_pattern = getcbpref('Spikes_cell_pattern'); continuous_channel = 'CSC'; % Get tags @@ -53,17 +53,17 @@ % Create names if nargin < 2 % if filename was not specified fname_spikes = fullfile(cellbase_datapath,ratname,session,tetrodeunit); - fname_events = fullfile(cellbase_datapath,ratname,session,session_fname); + fname_events = fullfile(cellbase_datapath,ratname,session,TrialEvents_fname); else % not really spikes, but whatever you specified % create unit filename if strncmpi(filename,'TrialEvent',10) - fname_unit = session_fname; %'TrialEvents2.mat'; + fname_unit = TrialEvents_fname; %'TrialEvents2.mat'; elseif strncmpi(filename,'StimEvent',9) - fname_unit = stim_fname; + fname_unit = StimEvents_fname; elseif strncmpi(filename,'Session',3) fname_unit = ''; - elseif strncmpi(filename,'Position',3), + elseif strncmpi(filename,'Position',3) fname_unit='POSITION'; elseif strncmpi(filename,'Spikes',5) fname_unit = sprintf('%s%d_%d.mat',cellbase_cell_pattern,tetrode,unit); diff --git a/CellBase_R2013a/Functions/database_functions/conversion/fname2cellid.m b/CellBase_R2013a/Functions/database_functions/conversion/fname2cellid.m index 18ca104..3d94251 100644 --- a/CellBase_R2013a/Functions/database_functions/conversion/fname2cellid.m +++ b/CellBase_R2013a/Functions/database_functions/conversion/fname2cellid.m @@ -28,7 +28,7 @@ cellbase_fname = getpref('cellbase','fname'); cellbase_path = getpref('cellbase','datapath'); if ispref('cellbase','cell_pattern') - cell_pattern = getpref('cellbase','cell_pattern'); + cell_pattern = getcbpref('Spikes_cell_pattern'); else cell_pattern = 'Sc'; end diff --git a/CellBase_R2013a/Help/CellBase_functions.html b/CellBase_R2013a/Help/CellBase_functions.html index 511529c..6e5bd81 100644 --- a/CellBase_R2013a/Help/CellBase_functions.html +++ b/CellBase_R2013a/Help/CellBase_functions.html @@ -43,6 +43,10 @@

Database functions

loadcb - Load the CellBase files
checknmcb - Check whether a CellBase name is valid
checkcb - Check main CellBase files
+getcbpref - Get CellBase-specific preference.
+setcbpref - Set CellBase-specific preference.
+default_preferences - Get default CellBase-specific preferences.
+import_preferences - Import CellBase-specific preferences.
upgradecb - Upgrade CellBase to new version

diff --git a/CellBase_R2013a/Help/MakeTrialEvents2_gonogo.html b/CellBase_R2013a/Help/MakeTrialEvents2_gonogo.html index f985857..64f8723 100644 --- a/CellBase_R2013a/Help/MakeTrialEvents2_gonogo.html +++ b/CellBase_R2013a/Help/MakeTrialEvents2_gonogo.html @@ -44,7 +44,7 @@

Description

trial events structure is saved under the name 'TrialEvents.mat'. This file becomes the primary store of behavioral data for a particular session; it is retrieved by loadcb via cellid2fnames. This default - file name is one of the preference settings of CellBase - type
getpref('cellbase','session_filename');

+ file name is one of the preference settings of CellBase - type
getcbpref('cellbase','TrialEvents_filename');

MakeTrialEvents2_gonogo(sessionpath,'StimNttl',TTL) specifies the TTL channel which serves as the basis for synchronization.

See Also

diff --git a/CellBase_R2013a/Help/default_preferences.html b/CellBase_R2013a/Help/default_preferences.html new file mode 100644 index 0000000..55c4e27 --- /dev/null +++ b/CellBase_R2013a/Help/default_preferences.html @@ -0,0 +1,49 @@ + + +default_preferences + + + + + +

default_preferences

+Get default CellBase-specific parameters. +

Syntax

+

+PREFERENCES = default_preferences() +

+

Description

+

default_preferences returns CellBase-specific default parameters in struct PREFERENCES. +Note that default_preferences is used for CellBase-specific parameters only, which are stored in your CellBase mat-file in the variable PREFERENCES. For global CellBase parameters use MATLAB function setpref/getpref('cellbase',...).

+ +

See Also

+

+ import_preferences, setcbpref,getcbpref +

+ + + diff --git a/CellBase_R2013a/Help/getcbpref.html b/CellBase_R2013a/Help/getcbpref.html new file mode 100644 index 0000000..7b6ecae --- /dev/null +++ b/CellBase_R2013a/Help/getcbpref.html @@ -0,0 +1,49 @@ + + +getcbpref + + + + + +

getcbpref

+Get CellBase-specific parameter. +

Syntax

+

+val = getcbpref(name) +

+

Description

+

getcbpref gets CellBase-specific parameter with name name and returns the parameters value in val. +Note that getcbpref is used for CellBase-specific parameters only, which are stored in your CellBase mat-file in the variable PREFERENCES. For global CellBase parameters use MATLAB function getpref('cellbase',name).

+ +

See Also

+

+setcbpref, default_preferences,initcb +

+ + + diff --git a/CellBase_R2013a/Help/import_preferences.html b/CellBase_R2013a/Help/import_preferences.html new file mode 100644 index 0000000..9a3c6a9 --- /dev/null +++ b/CellBase_R2013a/Help/import_preferences.html @@ -0,0 +1,52 @@ + + +import_preferences + + + + + +

import_preferences

+Create CellBase-specific default parameters or import old parameters. +

Syntax

+

+import_preferences() +

+

Description

+

import_preferences creates a struct PREFERENCES containing default parameters +or loads preferences from getpref('cellbase'). This is a +convenience function to maintain backwards compatibility to cellbase +5fbf007 (12 Sep 2017) and prior. +Note that import_preferences is used for CellBase-specific parameters only, which are stored in your CellBase mat-file in the variable PREFERENCES. For global CellBase parameters use MATLAB function setpref/getpref('cellbase',...).

+ +

See Also

+

+ default_preferences, setcbpref,getcbpref +

+ + + diff --git a/CellBase_R2013a/Help/setcbpref.html b/CellBase_R2013a/Help/setcbpref.html new file mode 100644 index 0000000..77538dd --- /dev/null +++ b/CellBase_R2013a/Help/setcbpref.html @@ -0,0 +1,49 @@ + + +setcbpref + + + + + +

setcbpref

+Set CellBase-specific parameter. +

Syntax

+

+setpref(name, value) +

+

Description

+

setcbpref sets CellBase-specific parameter with name name to value value. +Note that setcbpref is used for CellBase-specific parameters only, which are stored in your CellBase mat-file in the variable PREFERENCES. For global CellBase parameters use MATLAB function setpref('cellbase',...).

+ +

See Also

+

+getcbpref, default_preferences,initcb +

+ + + From 6f05f26f8dde993680838467f7b1b908104b2d4c Mon Sep 17 00:00:00 2001 From: "TORBEN-XPS\\torben" Date: Wed, 2 May 2018 11:11:53 -0400 Subject: [PATCH 2/2] minor improvements. --- .../database_functions/cellbase/getcbpref.m | 67 ++++++++++++------- .../cellbase/import_preferences.m | 2 +- .../database_functions/cellbase/setcbpref.m | 6 +- CellBase_R2013a/Help/default_preferences.html | 6 +- CellBase_R2013a/Help/getcbpref.html | 7 +- CellBase_R2013a/Help/import_preferences.html | 6 +- CellBase_R2013a/Help/setcbpref.html | 6 +- 7 files changed, 58 insertions(+), 42 deletions(-) diff --git a/CellBase_R2013a/Functions/database_functions/cellbase/getcbpref.m b/CellBase_R2013a/Functions/database_functions/cellbase/getcbpref.m index a89f887..f698c24 100644 --- a/CellBase_R2013a/Functions/database_functions/cellbase/getcbpref.m +++ b/CellBase_R2013a/Functions/database_functions/cellbase/getcbpref.m @@ -1,40 +1,55 @@ -function val = getcbpref(name) -% GETCBPREF() returns current cellbase's preference value for preference name STR. +function val = getcbpref(varargin) +% GETCBPREF returns current cellbase's preference value(s). % Cellbase-specific preferences are stored in cellbase file -% (getpref('cellbase','fname')). Note than cellbase-general preferences +% (getpref('cellbase','fname')). Note that cellbase-general preferences % (cellbase name, data folder, cellbase file) are manipulated with % getpref('cellbase')/setpref('cellbase',...). % -% Returns VAL, the value of preference NAME. Returns FALSE if n preference -% with NAME exists. +% Usage +% +% val = getcbpref() - returns all cellbase preferences in struct VAL (including global preferenes). +% val = getcbpref(name) - returns cellbase preference with name NAME in VAL. +% +% Example +% +% val = getcppref('TrialEvents_fname') % % See also: setcbpref(name,value), default_preferences() % % TO 05/2018 -if any(strcmp({'datapath','name','fname','filesep','cellbases'},name)) %global settings - warning('Please use getpref to get global cellbase settings.'); - val = getpref('cellbase',name); -else %correct use for cellbase-specific parameters - if exist(fullfile(getpref('cellbase','fname')),'file')==2 - P = load(fullfile(getpref('cellbase','fname')),'PREFERENCES'); - fields = fieldnames(P); - if ~isempty(fields) - P=P.PREFERENCES; - if isfield(P,name) - val=P.(name); - else %no parameter in PREFERENCES with that name - val = false; - warning('getcbpref: no parameter with the specified name found. Try setcbpref() first.'); +if nargin<2 + if nargin==1 && any(strcmp({'datapath','name','fname','filesep','cellbases'},varargin{1})) %global preferencces + warning('Please use getpref to get global cellbase settings.'); + val = getpref('cellbase',varargin{1}); + else %correct use for cellbase-specific preferences + if exist(fullfile(getpref('cellbase','fname')),'file')==2 + P = load(fullfile(getpref('cellbase','fname')),'PREFERENCES'); + fields = fieldnames(P); + if ~isempty(fields) + P=P.PREFERENCES; + if isempty(varargin) %get all + val = P; + val.datapath = getpref('cellbase','datapath'); + val.name = getpref('cellbase','name'); + val.fname = getpref('cellbase','fname'); + else + if isfield(P,varargin{1}) + val=P.(varargin{1}); + else %no parameter in PREFERENCES with that name + error('getcbpref: no parameter with the specified name found. Try setcbpref() first.'); + end + end + else %no preference file + import_preferences(); + val = getcbpref(varargin); end - else %no preference file - import_preferences(); - val=getcbpref(name); + + else %no cellbase + error('getcbpref: No Cellbase database found. Check cellbase filename.'); end - - else %no cellbase - error('getcbpref: No Cellbase database found. Check cellbase filename.'); end +else + error('getcbpref: Too many input arguments.') end -end \ No newline at end of file diff --git a/CellBase_R2013a/Functions/database_functions/cellbase/import_preferences.m b/CellBase_R2013a/Functions/database_functions/cellbase/import_preferences.m index 2f08abc..cdd1866 100644 --- a/CellBase_R2013a/Functions/database_functions/cellbase/import_preferences.m +++ b/CellBase_R2013a/Functions/database_functions/cellbase/import_preferences.m @@ -9,7 +9,7 @@ function import_preferences() % TO 05/2018 str = 'No PREFERENCE variable found. Likely due to use of older cellbase version. Please choose if you want to use default parameters or import from getpref("cellbase"). '; -str=strcat(str,'Preferences can be manipulated using getpref and setpref and are stored in your cellbase file.'); +str=strcat(str,'Preferences can be manipulated using getcbpref and setcbpref and are stored in your cellbase file.'); A = questdlg(str,'convert_preferences','Default','Import','Default'); diff --git a/CellBase_R2013a/Functions/database_functions/cellbase/setcbpref.m b/CellBase_R2013a/Functions/database_functions/cellbase/setcbpref.m index ad4f47e..3eecc28 100644 --- a/CellBase_R2013a/Functions/database_functions/cellbase/setcbpref.m +++ b/CellBase_R2013a/Functions/database_functions/cellbase/setcbpref.m @@ -2,7 +2,7 @@ function setcbpref(name,val) % SETCBPREF() sets current cellbase's preference value for preference NAME % to VAL. % Cellbase-specific preferences are stored in cellbase file -% (getpref('cellbase','fname')). Note than cellbase-general preferences +% (getpref('cellbase','fname')). Note that cellbase-general preferences % (cellbase name, data folder, cellbase file) are manipulated with % getpref('cellbase')/setpref('cellbase',...). % @@ -10,10 +10,10 @@ function setcbpref(name,val) % % TO 05/2018 -if any(strcmp({'datapath','name','fname','filesep','cellbases'},name)) %global settings +if any(strcmp({'datapath','name','fname','filesep','cellbases'},name)) %global preferences warning('Please use setpref to set global cellbase settings.'); setpref('cellbase',name,val); -else %correct use for cellbase-specific parameters +else %correct use for cellbase-specific preferences if exist(fullfile(getpref('cellbase','fname')),'file')==2 CB = load(fullfile(getpref('cellbase','fname'))); fields = fieldnames(CB); diff --git a/CellBase_R2013a/Help/default_preferences.html b/CellBase_R2013a/Help/default_preferences.html index 55c4e27..d3978c2 100644 --- a/CellBase_R2013a/Help/default_preferences.html +++ b/CellBase_R2013a/Help/default_preferences.html @@ -31,14 +31,14 @@

default_preferences

-Get default CellBase-specific parameters. +Get default CellBase-specific preferences.

Syntax

PREFERENCES = default_preferences()

Description

-

default_preferences returns CellBase-specific default parameters in struct PREFERENCES. -Note that default_preferences is used for CellBase-specific parameters only, which are stored in your CellBase mat-file in the variable PREFERENCES. For global CellBase parameters use MATLAB function setpref/getpref('cellbase',...).

+

default_preferences returns CellBase-specific default preferences in struct PREFERENCES. +Note that default_preferences is used for CellBase-specific preferences only, which are stored in your CellBase mat-file in the variable PREFERENCES. For global CellBase preferences use MATLAB function setpref/getpref('cellbase',...).

See Also

diff --git a/CellBase_R2013a/Help/getcbpref.html b/CellBase_R2013a/Help/getcbpref.html index 7b6ecae..0dbfb39 100644 --- a/CellBase_R2013a/Help/getcbpref.html +++ b/CellBase_R2013a/Help/getcbpref.html @@ -31,14 +31,15 @@

getcbpref

-Get CellBase-specific parameter. +Get CellBase-specific preference(s).

Syntax

+val = getcbpref()
val = getcbpref(name)

Description

-

getcbpref gets CellBase-specific parameter with name name and returns the parameters value in val. -Note that getcbpref is used for CellBase-specific parameters only, which are stored in your CellBase mat-file in the variable PREFERENCES. For global CellBase parameters use MATLAB function getpref('cellbase',name).

+

getcbpref returns all CellBase-specific preferences in struct val or value of preference with name name in val. +Note that getcbpref is used for CellBase-specific preferences only, which are stored in your CellBase mat-file in the variable PREFERENCES. For global CellBase preferences use MATLAB function getpref('cellbase',name).

See Also

diff --git a/CellBase_R2013a/Help/import_preferences.html b/CellBase_R2013a/Help/import_preferences.html index 9a3c6a9..15eb386 100644 --- a/CellBase_R2013a/Help/import_preferences.html +++ b/CellBase_R2013a/Help/import_preferences.html @@ -31,17 +31,17 @@

import_preferences

-Create CellBase-specific default parameters or import old parameters. +Create CellBase-specific default preferences or import old preferences.

Syntax

import_preferences()

Description

-

import_preferences creates a struct PREFERENCES containing default parameters +

import_preferences creates a struct PREFERENCES containing default preferences or loads preferences from getpref('cellbase'). This is a convenience function to maintain backwards compatibility to cellbase 5fbf007 (12 Sep 2017) and prior. -Note that import_preferences is used for CellBase-specific parameters only, which are stored in your CellBase mat-file in the variable PREFERENCES. For global CellBase parameters use MATLAB function setpref/getpref('cellbase',...).

+Note that import_preferences is used for CellBase-specific preferences only, which are stored in your CellBase mat-file in the variable PREFERENCES. For global CellBase preferences use MATLAB function setpref/getpref('cellbase',...).

See Also

diff --git a/CellBase_R2013a/Help/setcbpref.html b/CellBase_R2013a/Help/setcbpref.html index 77538dd..b5314c8 100644 --- a/CellBase_R2013a/Help/setcbpref.html +++ b/CellBase_R2013a/Help/setcbpref.html @@ -31,14 +31,14 @@

setcbpref

-Set CellBase-specific parameter. +Set CellBase-specific preference.

Syntax

setpref(name, value)

Description

-

setcbpref sets CellBase-specific parameter with name name to value value. -Note that setcbpref is used for CellBase-specific parameters only, which are stored in your CellBase mat-file in the variable PREFERENCES. For global CellBase parameters use MATLAB function setpref('cellbase',...).

+

setcbpref sets CellBase-specific preference with name name to value value. +Note that setcbpref is used for CellBase-specific preferences only, which are stored in your CellBase mat-file in the variable PREFERENCES. For global CellBase preferences use MATLAB function setpref('cellbase',...).

See Also