Skip to content

Commit

Permalink
Merge branch 'develop' into 758-pspm_expand_epochs
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikbach authored Oct 28, 2024
2 parents 0285c10 + a53785d commit d4bd1ec
Show file tree
Hide file tree
Showing 22 changed files with 294 additions and 169 deletions.
4 changes: 2 additions & 2 deletions src/pspm_cfg/pspm_cfg_help_format.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
['This GUI item calls the function %s. You can also call this function ', ...
'directly. Type ''help %s'' in the command window for more information.'], funcname, funcname), ...
'------------------------------------------------------------------------------------------------'};

if isfield(settings.help, funcname)
if isfield(settings.help.(funcname), 'Description')
A = settings.help.(funcname).Description;
Expand Down Expand Up @@ -56,4 +56,4 @@
helptext = helptext(2:end);
end
helptext = {helptext};
end
end
2 changes: 1 addition & 1 deletion src/pspm_cfg/pspm_cfg_selector_data_design.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Binary file modified src/pspm_data_editor.fig
Binary file not shown.
37 changes: 20 additions & 17 deletions src/pspm_data_editor.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ function pspm_data_editor_OpeningFcn(hObject, ~, handles, varargin)
handles.input_mode = '';
handles.input_file = '';
handles.output_file = '';
set(handles.fgDataEditor, 'WindowButtonDownFcn', @buttonDown_Callback);
set(handles.fgDataEditor, 'WindowButtonUpFcn', @buttonUp_Callback);
set(handles.fgDataEditor, 'WindowButtonMotionFcn', @buttonMotion_Callback);
set(handles.pspm_data_editor, 'WindowButtonDownFcn', @buttonDown_Callback);
set(handles.pspm_data_editor, 'WindowButtonUpFcn', @buttonUp_Callback);
set(handles.pspm_data_editor, 'WindowButtonMotionFcn', @buttonMotion_Callback);
if numel(varargin) > 1 && isstruct(varargin{2}) % load options
handles.options = varargin{2};
handles.options = pspm_options(handles.options, 'data_editor');
Expand Down Expand Up @@ -139,7 +139,7 @@ function pspm_data_editor_OpeningFcn(hObject, ~, handles, varargin)
Add_Epochs(hObject, handles)
end
end
uiwait(handles.fgDataEditor);
uiwait(handles.pspm_data_editor);

function [sts] = CreateOutput(hObject)
handles = guidata(hObject);
Expand Down Expand Up @@ -230,7 +230,7 @@ function loadFromFile(hObject, file)
[~, infos, data] = pspm_load_data(file); % load file
channels = cellfun(@(x) {x.header.chantype,x.header.units}, data, 'UniformOutput', 0);
set(handles.edOpenFilePath, 'String', file);
corder = get(handles.fgDataEditor, 'defaultAxesColorOrder'); % format channels
corder = get(handles.pspm_data_editor, 'defaultAxesColorOrder'); % format channels
cl = length(corder)-2;
disp_names = cell(numel(channels), 1);
for i = 1:numel(channels)
Expand All @@ -255,6 +255,7 @@ function loadFromFile(hObject, file)
PlotData(hObject);

function PlotData(hObject)
global settings
handles = guidata(hObject);
channel = {};
switch handles.input_mode % load data
Expand Down Expand Up @@ -286,13 +287,14 @@ function PlotData(hObject)
end

function AddPlot(hObject, chan_id, action)
global settings
handles = guidata(hObject);
if isempty(action)
action = 'replace';
end
np = get(handles.axData, 'NextPlot');
set(handles.axData, 'NextPlot', action);
corder = get(handles.fgDataEditor, 'defaultAxesColorOrder');
corder = get(handles.pspm_data_editor, 'defaultAxesColorOrder');
cl = length(corder)-2;
m = floor((chan_id-0.1)/cl);
color = corder(chan_id - m*cl, :);
Expand Down Expand Up @@ -339,6 +341,7 @@ function AddPlot(hObject, chan_id, action)
guidata(hObject, handles);

function RemovePlot(hObject, chan_id)
global settings
handles = guidata(hObject);
if numel(handles.plots) >= chan_id
for i = 1:numel(handles.epochs) % remove response plots
Expand Down Expand Up @@ -496,11 +499,11 @@ function lbEpochs_CreateFcn(hObject, ~, ~)
set(hObject,'BackgroundColor','white');
end

function fgDataEditor_CreateFcn(~, ~, ~)
function pspm_data_editor_CreateFcn(~, ~, ~)
% Feature
% Executes during object creation, after setting all properties.
% Variables
% hObject handle to fgDataEditor (see GCBO)
% hObject handle to pspm_data_editor (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

Expand Down Expand Up @@ -917,7 +920,7 @@ function pbApply_Callback(hObject, ~, handles)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if CreateOutput(hObject) == 1
uiresume(handles.fgDataEditor);
uiresume(handles.pspm_data_editor);
end

function pbCancel_Callback(hObject, ~, handles)
Expand All @@ -929,8 +932,8 @@ function pbCancel_Callback(hObject, ~, handles)
% handles structure with handles and user data (see GUIDATA)
handles.output = {};
guidata(hObject, handles);
if isfield(handles, 'fgDataEditor')
uiresume(handles.fgDataEditor);
if isfield(handles, 'pspm_data_editor')
uiresume(handles.pspm_data_editor);
end

function cbInterpolate_Callback(hObject, ~, ~)
Expand Down Expand Up @@ -958,18 +961,18 @@ function ppOutput_CreateFcn(hObject, ~, ~)
set(hObject,'BackgroundColor','white');
end

function fgDataEditor_CloseRequestFcn(hObject, ~, handles)
function pspm_data_editor_CloseRequestFcn(hObject, ~, handles)
% Feature
% Executes when user attempts to close fgDataEditor.
% Executes when user attempts to close pspm_data_editor.
% Variables
% hObject handle to fgDataEditor (see GCBO)
% hObject handle to pspm_data_editor (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint
% delete(hObject) closes the figure
handles.output = {};
if isfield(handles, 'fgDataEditor')
uiresume(handles.fgDataEditor);
if isfield(handles, 'pspm_data_editor')
uiresume(handles.pspm_data_editor);
end
delete(hObject);

Expand Down Expand Up @@ -1039,7 +1042,7 @@ function rbInterpolate_Callback(hObject, eventdata, handles)
% selection changed callback
bgOutputFormat_SelectionChangedFcn(hObject, eventdata, handles);

function pbOpenInputFile_Callback(hObject, ~, handles)
function pbOpenInputFile_Callback(hObject, ~, handles, varargin)
% Feature
% Executes on button press in pbOpenInputFile.
% Variables
Expand Down
Binary file modified src/pspm_display.fig
Binary file not shown.
16 changes: 6 additions & 10 deletions src/pspm_display.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ function pspm_display_OpeningFcn(hObject, ~, handles, varargin)
if isempty(settings)
pspm_init;
end

% load channeltypes from settings variable

j = 1 ; l = 1;
Expand Down Expand Up @@ -156,8 +155,11 @@ function pspm_display_OpeningFcn(hObject, ~, handles, varargin)
% Update handles structure
guidata(hObject, handles);

handles.pspm_display.HandleVisibility = settings.handle;

% UIWAIT makes pspm_display wait for user response (see UIRESUME)
% uiwait(handles.figure1);
%uiwait(handles.pspm_display);

end


Expand Down Expand Up @@ -523,7 +525,7 @@ function saveas_Callback(~, ~, handles)
close(q)
end
% --------------------------------------------------------------------
function exit_Callback(~, ~, ~)
function exit_Callback(~, ~, handles)
% hObject handle to exit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Expand Down Expand Up @@ -693,14 +695,8 @@ function edit_y_max_CreateFcn(hObject, ~, ~)
%% pp_plot

function pp_plot(handles)

global settings;
if isempty(settings)
pspm_init;
end

% ---header----------------------------------------------------------------

global settings
% handles.name ... filename
% prop... struct with fields
% .wave (channel number)
Expand Down
22 changes: 14 additions & 8 deletions src/pspm_doc.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,33 @@
% 3.1 Add title
Title = pspm_doc_get_title(func_name);
M = [M, '# ', Title, newline];
M = [M, '[Back to index](/PsPM/ref/)', newline];
% 3.2 Add description
if isfield(S, 'Description')
Description = pspm_doc_get_description(S.Description);
M = [M, '## ', 'Description', newline, Description, newline];
M = [M, newline, '## ', 'Description', newline, newline, Description, newline, newline];
end
% 3.3 Add format
if isfield(S, 'Format')
Format = pspm_doc_get_format(S.Format);
M = [M, '## ', 'Format', newline, Format, newline];
M = [M, '## ', 'Format', newline, newline, Format, newline, newline];
end
% 3.4 Add arguments
if isfield(S, 'Arguments')
Arguments = pspm_doc_get_struct_fields(S.Arguments);
M = [M, '## ', 'Arguments', newline, Arguments, newline];
M = [M, '## ', 'Arguments', newline, newline, Arguments, newline, newline];
end
% 3.5 Add outputs
if isfield(S, 'Outputs')
Outputs = pspm_doc_get_struct_fields(S.Outputs);
M = [M, '## ', 'Outputs', newline, Outputs, newline];
M = [M, '## ', 'Outputs', newline, newline, Outputs, newline, newline];
end
% 3.6 Add references
if isfield(S, 'References')
References = pspm_doc_get_references(S.References);
M = [M, '## ', 'References', newline, References, newline];
M = [M, '## ', 'References', newline, newline, References, newline, newline];
end
M = [M, '[Back to index](/PsPM/ref/)', newline];
%% 4 Write to file
if isfield(options, 'path')
writelines(M, [options.path, '/', Title,'.md']);
Expand Down Expand Up @@ -85,7 +87,6 @@
end
Y(LocRm) = [];
Y = [Y, newline];

end
function Y = pspm_doc_get_description(X)
X = insertAfter(X, newline, newline);
Expand All @@ -99,7 +100,7 @@
case 'char'
Y = [Y, '| ', list_arg{i_arg}, ' | ', X.(list_arg{i_arg}), ' |', newline];
case 'struct'
Y = [Y, '| ', list_arg{i_arg}, ' | ', 'See following fields.' , ' |', newline];
Y = [Y, '| ', list_arg{i_arg}, ' | ', 'See following fields.', ' |', newline];
list_arg2 = fieldnames(X.(list_arg{i_arg}));
for i_arg2 = 1:length(list_arg2)
switch class(X.(list_arg{i_arg}).(list_arg2{i_arg2}))
Expand All @@ -112,12 +113,17 @@
for i_arg3 = 1:length(list_arg3)
Y = [Y, '| ', list_arg{i_arg}, '.', list_arg2{i_arg2}, '.', list_arg3{i_arg3}, ' | ', ...
X.(list_arg{i_arg}).(list_arg2{i_arg2}).(list_arg3{i_arg3}), ' |'];
Y = [Y, newline];
if i_arg3 < length(list_arg3)
Y = [Y, newline];
end
end
end
if i_arg2 < length(list_arg2)
Y = [Y, newline];
end
if i_arg2 == length(list_arg2) && isstruct(X.(list_arg{i_arg}).(list_arg2{i_arg2}))
Y = [Y, newline];
end
end
end
end
Expand Down
80 changes: 80 additions & 0 deletions src/pspm_doc_gen.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
function sts = pspm_doc_gen(varargin)
% ● Description
% pspm_doc_gen generates the documents of help text
% in pspm functions into markdown files.
% ● Format
% sts = pspm_doc_gen()
% sts = pspm_doc_gen({'pspm_dcm'})
% sts = pspm_doc_gen('/Users/pspm/')
% sts = pspm_doc_gen({'pspm_dcm'}, '/Users/pspm/')
% ● History
% Introduced in PsPM 7.0
% Written in 2024 by Teddy

global settings
if isempty(settings)
pspm_init;
end
sts = 1;
switch nargin
case 0
savepath = [settings.path, '/ref'];
mkdir(savepath);
case 1
switch class(varargin{1})
case 'char'
savepath = varargin{1};
case 'cell'
savepath = [settings.path, '/ref'];
mkdir(savepath);
list_func = varargin{1};
end
case 2
list_func = varargin{1};
savepath = varargin{2};
end
if ~exist('list_func', 'var')
list_func = { ...
'pspm_trim', ...
'pspm_split_sessions', ...
'pspm_merge', ...
'pspm_rename', ...
'pspm_combine_markerchannels', ...
'pspm_convert_area2diameter', ...
'pspm_convert_au2unit', ...
'pspm_convert_ecg2hb', ...
'pspm_convert_ecg2hb_amri', ...
'pspm_convert_gaze', ...
'pspm_convert_hb2hp', ...
'pspm_convert_ppg2hb', ...
'pspm_emg_pp', ...
'pspm_find_sounds', ...
'pspm_find_valid_fixations', ...
'pspm_gaze_pp', ...
'pspm_interpolate', ...
'pspm_pp', ...
'pspm_pupil_correct_eyelink', ...
'pspm_pupil_pp', ...
'pspm_remove_epochs', ...
'pspm_resp_pp', ...
'pspm_scr_pp', ...
'pspm_dcm', ...
'pspm_glm', ...
'pspm_process_illuminance', ...
'pspm_sf', ...
'pspm_tam', ...
'pspm_export', ...
'pspm_extract_segments', ...
'pspm_get_markerinfo' ...
};
end
for i_func = 1:length(list_func)
options = struct();
options.path = savepath;
disp(list_func{i_func});
sts_temp = pspm_doc(list_func{i_func}, options);
if sts_temp == -1
sts = -1;
end
end
end
Binary file modified src/pspm_ecg_editor.fig
Binary file not shown.
Loading

0 comments on commit d4bd1ec

Please sign in to comment.