Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New event import functionality: You can now either load new event mar…
…kers from a text file and (1) delete the existing ones, (2) keep the existing ones, (3) recode the existing ones.
- Loading branch information
1 parent
a945c4e
commit d897ca6
Showing
8 changed files
with
184 additions
and
13 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,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 | ||
|
||
-------------------------------------------------------------------------- | ||
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 |
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 |
---|---|---|
@@ -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 | ||
|
||
|
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 |
---|---|---|
@@ -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 |
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
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