diff --git a/Ledalab.m b/Ledalab.m index d1e7bee..c6127e5 100644 --- a/Ledalab.m +++ b/Ledalab.m @@ -7,7 +7,7 @@ function Ledalab(varargin) global leda2 leda2.intern.name = 'Ledalab'; -leda2.intern.version = 3.46; +leda2.intern.version = 3.47; versiontxt = num2str(leda2.intern.version,'%3.2f'); leda2.intern.versiontxt = ['V',versiontxt(1:3),'.',versiontxt(4:end)]; leda2.intern.version_datestr = '2014-05-20'; diff --git a/What's new.txt b/What's new.txt index 039fbd9..969191f 100644 --- a/What's new.txt +++ b/What's new.txt @@ -1,7 +1,59 @@ -What's new in Ledalab V.3.4.6? +What's new in Ledalab V.3.4.7? -- Biotrace import function now supports UK format in addition to DE version. -- Butterworth-filter function extended (lower cutoff and order can be set to create a low-pass filter) -- Filter function now included to batchmode analysis -- PhasicMax score (i.e., maximum phasic driver value within response window) added to event-related activation scores -- Minor debugging of graphic functions \ No newline at end of file + +-------------------------------------------------------------------------- +NEW EVENT IMPORT FUNCTIONS + +Changed files: +- import_eventdata.m (infotype switch modified) +- import_eventinfo.m (infotype switch modified) +- ledagui.m (now refers to getevents.m by default) + +Added files: +- getevents.m (new event marker read function for import_eventdata.m and import_eventinfo.m) +- import_addeventdata.m (new function to add newly imported event markers while keeping the old ones) + + + +Changed functionality for importing event markers: + + +Option 1; File -> Import Events -> Load New Event Markers (and DELETE exisiting ones): +To load new markers from a text file and and DELETE the already existing ones. + +You need a text-file with tab-separated columns and titles in the first row. You can use additional user-specified columns if you like and give them arbitrary titles. +You need at least the columns 'time' and 'nid', the rest is optional. +- 'time' --> time of event relative to first sample point in seconds (numeric) +- 'nid' --> numeric ID of the marker indicating the experimental condition (integer) +- 'name' --> name of the marker (string) + + +Option 2; File -> Import Events -> Load New Event Markers (and KEEP exisiting ones): +To load new markers from a text file and KEEP the already existing ones. + +You need a text-file with tab-separated columns and titles in the first row. You can use additional user-specified columns if you like and give them arbitrary titles. +You need at least the columns 'time' and 'nid', the rest is optional. +- 'time' --> time of event relative to first sample point in seconds (numeric) +- 'nid' --> numeric ID of the marker indicating the experimental condition (integer) +- 'name' --> name of the marker (string) + + +Oprtion 3: File -> Import Events -> Recode Existing Events Markers +To recode existing markers from a text file with the same number of rows as there are existing markers. + +You need a text-file with tab-separated columns and titles in the first row. You can use additional user-specified columns if you like and give them arbitrary titles. +You need at least one of these columns. +- 'time' --> time of event relative to first sample point in seconds (numeric) +- 'nid' --> ID of the marker indicating the experimental condition (integer) +- 'name' --> name of the marker (string) + + + +-------------------------------------------------------------------------- +BUG IN DATA IMPORT FUNCTION + +Changed files: +- import_data.m (infotype switch modified) + +line54 +% timeoffset = data.timeoff; %JG 27.9.2012 \ No newline at end of file diff --git a/main/import/getevents.m b/main/import/getevents.m new file mode 100644 index 0000000..cdcf33d --- /dev/null +++ b/main/import/getevents.m @@ -0,0 +1,38 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% new event marker read function for import_eventdata.m and import_eventinfo.m +% by Til Ole Bergmann, bergmann@psychologie.uni-kiel.de +% last edit 2014-06-13 by TOB +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function event = getevents(fullpath) + +% read in text file with unknown number of columns into cell array +fid = fopen(fullpath); +firstLine = fgetl(fid); +fclose(fid); +numFields = length(strfind(firstLine,sprintf('\t'))) + 1; +formatString = repmat('%s',1,numFields); +fid = fopen(fullpath); +C = textscan(fid, formatString,'\t'); +fclose(fid); + +for ev = 1:size(C{1},1)-1 % starts in line 2 as first line contians header + for nf = 1:numFields + event(ev).userdata = []; + switch C{nf}{1} + case 'time' + event(ev).time = str2num(C{nf}{1+ev}); + case 'nid' + event(ev).nid = str2num(C{nf}{1+ev}); + if ~isfield(event(ev),'name') + event(ev).name = num2str(event(ev).nid); + end + case 'name' + event(ev).name = C{nf}{1+ev}; + otherwise % user specific data will be stored in cell array + event(ev).userdata.(C{nf}{1}) = C{nf}{1+ev}; + end + end +end + + diff --git a/main/import/import_addeventdata.m b/main/import/import_addeventdata.m new file mode 100644 index 0000000..a4eac2e --- /dev/null +++ b/main/import/import_addeventdata.m @@ -0,0 +1,76 @@ +function import_addeventdata(infotype) +global leda2 + +if ~leda2.file.open + add2log(0,'No open file',1,1,0,1,0,1) + return; +end + +[filename, pathname] = uigetfile({'*.txt';'*.dat'},'Choose an event-data file'); + +if all(filename == 0) || all(pathname == 0) %Cancel + return +end + + +switch infotype + case 'default', + event = getevents([pathname, filename]); + case 'userdef', + event = getuserdefeventdata([pathname, filename]); +end + + +if ~isempty(event) + old_event = leda2.data.events.event; % copy old events + old_events_N = leda2.data.events.N; % copy number of old events + leda2.data.events.event = []; % clear events structure + + N = length(event); + event_fields = fieldnames(event); + + for ev = 1:N + if any(strcmp(event_fields, 'time')) + leda2.data.events.event(ev).time = event(ev).time; + end + if any(strcmp(event_fields, 'name')) + leda2.data.events.event(ev).name = event(ev).name; + end + if any(strcmp(event_fields, 'nid')) + leda2.data.events.event(ev).nid = event(ev).nid; + end + if any(strcmp(event_fields, 'userdata')) + leda2.data.events.event(ev).userdata = event(ev).userdata; + end + leda2.data.events.N = N; % get number of new events + end + + new_event = leda2.data.events.event; % copy new events + leda2.data.events.event = []; % clear events structure + + + %% merge old and new events + % merge old and new marker structure array + M = [old_event, new_event]; + + % convert structure array to cell array + Mfields = fieldnames(M); + Mcell = struct2cell(M); + sz = size(Mcell); + Mcell = reshape(Mcell, sz(1), []); % convert to a matrix + Mcell = Mcell'; % Make each field a column + + % sort + Mcell = sortrows(Mcell, 1); % Sort by first field "time" + + % convert it back to a structure array: + Mcell = reshape(Mcell', sz); % put back into original cell array format + Msorted = cell2struct(Mcell, Mfields, 1); % convert to struct + + % pass over new values to leda2.data.events + leda2.data.events.event = Msorted; + leda2.data.events.N = leda2.data.events.N + old_events_N; + + plot_data; + +end diff --git a/main/import/import_data.m b/main/import/import_data.m index e18393b..98b8ee1 100644 --- a/main/import/import_data.m +++ b/main/import/import_data.m @@ -52,7 +52,7 @@ function import_data(datatype, pathname, filename) conductance = data.conductance; time = data.time; event = data.event; - timeoffset = data.timeoff; %JG 27.9.2012 +% timeoffset = data.timeoff; %JG 27.9.2012 case 'text' [time, conductance, event] = gettextdata(file); diff --git a/main/import/import_eventdata.m b/main/import/import_eventdata.m index ac60356..2c5c0e5 100644 --- a/main/import/import_eventdata.m +++ b/main/import/import_eventdata.m @@ -6,7 +6,7 @@ function import_eventdata(infotype) return; end -[filename, pathname] = uigetfile({'*.txt';'*.dat'},'Choose a Event-file'); +[filename, pathname] = uigetfile({'*.txt';'*.dat'},'Choose an event-data file'); if all(filename == 0) || all(pathname == 0) %Cancel return @@ -14,6 +14,8 @@ function import_eventdata(infotype) switch infotype + case 'default', + event = getevents([pathname, filename]); case 'userdef', event = getuserdefeventdata([pathname, filename]); end diff --git a/main/import/import_eventinfo.m b/main/import/import_eventinfo.m index a6dd847..d31135a 100644 --- a/main/import/import_eventinfo.m +++ b/main/import/import_eventinfo.m @@ -2,7 +2,7 @@ function import_eventinfo(infotype) global leda2 -[filename, pathname] = uigetfile({'*.txt';'*.dat'},'Choose a Eventinfo-file'); +[filename, pathname] = uigetfile({'*.txt';'*.dat'},'Choose an event-info file'); if all(filename == 0) || all(pathname == 0) %Cancel return @@ -10,6 +10,8 @@ function import_eventinfo(infotype) switch infotype + case 'default', + event = getevents([pathname, filename]); case 'userdef', event = getuserdefeventinfo([pathname, filename]); end @@ -38,7 +40,7 @@ function import_eventinfo(infotype) %plot updated event-names for ev = 1:N - set(leda2.gui.rangeview.eventtxt(ev),'String',sprintf('%.1f: %s (%s)',leda2.data.events.event(ev).time, leda2.data.events.event(ev).name), num2str(leda2.data.events.event(ev).nid)); + set(leda2.gui.rangeview.eventtxt(ev),'String',sprintf('%.1f: %s (%s)',leda2.data.events.event(ev).time, leda2.data.events.event(ev).name, num2str(leda2.data.events.event(ev).nid))); end end diff --git a/main/ledagui.m b/main/ledagui.m index 2f8c768..4cb0ea1 100644 --- a/main/ledagui.m +++ b/main/ledagui.m @@ -26,8 +26,9 @@ leda2.gui.menu.menu_1b14 = uimenu(leda2.gui.menu.menu_1b,'Label','User-defined Data','Callback','import_data(''userdef'');','Enable','off'); leda2.gui.menu.menu_1c = uimenu(leda2.gui.menu.menu_1,'Label','Import Events...'); %,'Accelerator','i' -leda2.gui.menu.menu_1c1 = uimenu(leda2.gui.menu.menu_1c,'Label','Event-Data [Time (Marker)]','Callback','import_eventdata(''userdef'')'); -leda2.gui.menu.menu_1c2 = uimenu(leda2.gui.menu.menu_1c,'Label','User-defined Event-Labels','Callback','import_eventinfo(''userdef'')'); +leda2.gui.menu.menu_1c1 = uimenu(leda2.gui.menu.menu_1c,'Label','Load New Event Markers (and DELETE exisiting ones)','Callback','import_eventdata(''default'')'); +leda2.gui.menu.menu_1c1 = uimenu(leda2.gui.menu.menu_1c,'Label','Load New Event Markers (and KEEP exisiting ones)','Callback','import_addeventdata(''default'')'); +leda2.gui.menu.menu_1c2 = uimenu(leda2.gui.menu.menu_1c,'Label','Recode Existing Event Markers','Callback','import_eventinfo(''default'')'); leda2.gui.menu.menu_1d = uimenu(leda2.gui.menu.menu_1,'Label','Export Data...'); leda2.gui.menu.menu_1d1 = uimenu(leda2.gui.menu.menu_1d,'Label','ASCII File','Callback','exportTextData'); leda2.gui.menu.menu_1e = uimenu(leda2.gui.menu.menu_1,'Label','Save','Callback','save_ledafile','Accelerator','s','Separator','on');