diff --git a/src/pspm_cfg/pspm_cfg_selector_data_design.m b/src/pspm_cfg/pspm_cfg_selector_data_design.m index 6bd7fe03..19b91dc8 100644 --- a/src/pspm_cfg/pspm_cfg_selector_data_design.m +++ b/src/pspm_cfg/pspm_cfg_selector_data_design.m @@ -74,7 +74,7 @@ end % marker channel if isfield(job.timeunits, 'markers') - options.marker_chan_num = pspm_cfg_channel_selector('run', job.timeunits.markers.chan); + options.marker_chan_num = pspm_cfg_selector_channel('run', job.timeunits.markers.chan); end out1 = model; out2 = options; diff --git a/src/pspm_extract_segments.m b/src/pspm_extract_segments.m index bd8ae4bc..9fe869ff 100644 --- a/src/pspm_extract_segments.m +++ b/src/pspm_extract_segments.m @@ -332,24 +332,13 @@ % ensure correct file suffix [pt, fn, ~] = fileparts(options.outputfile); outfile = [pt filesep fn '.mat']; - write_ok = 0; - if exist(outfile, 'file') - if options.overwrite - write_ok = 1; - else - button = questdlg(sprintf('File (%s) already exists. Replace file?', ... - outfile), 'Replace file?', 'Yes', 'No', 'No'); - - write_ok = strcmpi(button, 'Yes'); - end - else - write_ok = 1; - end - - if write_ok + + if pspm_overwrite(options.outputfile, options.overwrite) save(outfile, 'segments'); - out.outputfile = outfile; + out.outputfile = outfile; end + + end if options.plot diff --git a/src/pspm_review.fig b/src/pspm_review.fig index 79f0e237..28b0ec60 100644 Binary files a/src/pspm_review.fig and b/src/pspm_review.fig differ diff --git a/src/pspm_review.m b/src/pspm_review.m index 8772eb2f..a133eb43 100644 --- a/src/pspm_review.m +++ b/src/pspm_review.m @@ -5,6 +5,7 @@ % Introduced in PsPM 3.0 % Written in 2008-2015 by Gabriel Graeni (University of Zurich) % Maintained in 2022 by Teddy +% Maintained in 2024 by Bernhard Agoué von Raußendorf %% Initialise global settings @@ -47,10 +48,11 @@ function pspm_review_OpeningFcn(hObject, ~, handles, varargin) set(handles.textPlot4,'HorizontalAlignment','left') set(handles.textPlot5,'HorizontalAlignment','left') set(handles.textPlot6,'HorizontalAlignment','left') +set(handles.textPlot7,'HorizontalAlignment','left') set(handles.textStatus,'HorizontalAlignment','left') set(handles.textStatus,'String','Select a model...'); -handles.nrPlot = 6; +handles.nrPlot = 7; %handles.figCnt = 0; handles.modelCnt = 0; handles.currentModel = 1; @@ -303,6 +305,7 @@ function buttonPlot5_Callback(hObject, ~, handles) set(handles.textStatus,'String',tmpStatusString); guidata(hObject, handles); + % --- Executes on button press in buttonPlot6. function buttonPlot6_Callback(hObject, ~, handles) % hObject handle to buttonPlot6 (see GCBO) @@ -310,6 +313,60 @@ function buttonPlot6_Callback(hObject, ~, handles) % handles structure with handles and user data (see GUIDATA) tmpStatusString = get(handles.textStatus,'String'); set(handles.textStatus,'String','Plotting is in progress. Please wait...'); +switch handles.modelData{handles.currentModel}.modeltype + case 'glm' + + modelfile = handles.modelData{handles.currentModel}.modelfile; + options = struct(); + [ssts, segments] = pspm_extract_segments('model', modelfile, options); + + if ssts == -1 + uiwait(msgbox('Error extracting segments from the model.', 'Error')) + else + + glm = handles.modelData{handles.currentModel}.model; + sr = glm.input.sr; + cmap = lines(numel(segments.segments)); + f.h = figure; + f.a.h = axes(f.h); + hold on; + + legendNames = cell(1, numel(segments.segments)); + + for x = 1:numel(segments.segments) + + plotdata = segments.segments{x}.mean; + t = (1:length(plotdata)) / sr; + f.a.p = plot(f.a.h, t, plotdata, 'Color', cmap(x, :), 'LineWidth', 1); + legendNames{x} = segments.segments{x}.name; + + end + + f.a.l = legend(legendNames, 'Interpreter', 'none', 'Location', 'best'); + legend boxoff + + set(get(f.a.h, 'xlabel'), 'String', 'Time (seconds)'); + set(get(f.a.h, 'ylabel'), 'String', 'Mean Response (data units)'); + set(get(f.a.h, 'title'), 'String', 'Mean Responses for All Segments'); + + hold off; + end + + + +end + +set(handles.textStatus,'String',tmpStatusString); +guidata(hObject, handles); + + +% --- Executes on button press in buttonPlot7. +function buttonPlot7_Callback(hObject, ~, handles) +% hObject handle to buttonPlot7 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +tmpStatusString = get(handles.textStatus,'String'); +set(handles.textStatus,'String','Plotting is in progress. Please wait...'); switch handles.modelData{handles.currentModel}.modeltype case 'glm' [~, handles.modelData{handles.currentModel}.fig] = ... @@ -463,16 +520,18 @@ function showModel(handles) 'Plot', ... 'Plot', ... 'Show', ... + 'Plot', ... 'Plot'}; textPlotString = {'Design matrix in SPM style', ... 'Orthogonality in SPM style', ... 'Predicted & observed', ... 'Regressors in command window', ... - 'Reconstructed responses'}; + 'Reconstructed responses', ... + 'Plot data per condition'}; % detect contrasts if isfield(handles.modelData{handles.currentModel}.model, 'con') - buttonPlotString{6} = 'Show'; - textPlotString{6} = 'Contrast names in command window'; + buttonPlotString{7} = 'Show'; + textPlotString{7} = 'Contrast names in command window'; end setInvisble(handles); setButtonPlotString(handles, buttonPlotString); diff --git a/src/pspm_ui.m b/src/pspm_ui.m index bf16a1d3..13039981 100644 --- a/src/pspm_ui.m +++ b/src/pspm_ui.m @@ -8,6 +8,7 @@ % ● History % Introduced in PsPM 5.1 % Written and maintained in 2021-2022 +% Maintained in 2024 by Bernhard von Raußendorf %% Initialise global settings @@ -262,6 +263,10 @@ 'buttonPlot4',... 'textPlot5',... 'buttonPlot5',... + 'textPlot6',... + 'buttonPlot6',... + 'textPlot7',... + 'buttonPlot7',... 'buttonPlotClose',... 'textSessionNr',... 'editSessionNr',...