Coder Social home page Coder Social logo

bachlab / pspm Goto Github PK

View Code? Open in Web Editor NEW
41.0 5.0 11.0 200.82 MB

A matlab suite for Psycho-Physiological Modelling

License: GNU General Public License v3.0

MATLAB 97.05% C 1.40% Mathematica 0.37% M 0.69% C++ 0.39% Shell 0.05% Roff 0.05% Limbo 0.01% Python 0.01%
psychophysiology matlab-toolbox matlab matlab-gui scientific-research scr ecg eeg pupil bioinformatics

pspm's Introduction

PsPM

GitHub release (latest by date) GitHub Release Date Website License

PsPM stands for PsychoPhysiological Modelling. It is a powerful MATLAB toolbox for model-based analysis of psychophysiological signals, for example skin conductance response (SCR), electrocardiography (ECG), respiration, pupil size, or startle eye-blink electromyography (EMG). Currently, PsPM implements models for all of these modalities and the data formats they use. We are working towards further models, for example, for skin potential and ocular scan path length.

PsPM allows inferring a psychological variable from observable physiological data. For example, associative memory can be inferred from observed SCR signals. This allows for quantitative description of hidden processes, increases the temporal resolution of analysis, and suppresses noise.

PsPM implements simple General Linear Convolution Models (GLMs) for evoked SCR, or uses the Dynamic Causal Modelling (DCM) framework — as a tool to invert more complicated, non-linear models of SCR signals, for example for spontaneous fluctuations or anticipatory responses. Inference is drawn in a hierarchical summary-statistic approach (similar to SPM software for functional magnetic resonance imaging).

PsPM also supports other kinds of data for which no models exist yet, in particular we have extended support for eyetracking data.

The flexible software allows import of a number of data formats, including Spike, Biopac, VarioPort, (exported) ADInstruments LabChart, (exported) Biograph Infiniti, (exported) MindMedia BioTrace, Dataq/Windaq, AckKnowledge, ScanPhysLog, EDF, (exported) Eyelink, Matlab, and Text files. We are working on the support towards Brain Imaging Data Structure (BIDS) and expect to include the feature in the release 6.2.

Further features are simple programming of add-ons for import and modelling of new data types and automatic creation of batch scripts via the GUI.

PsPM incorporates the previous software package SCRalyze and offers all features of SCRalyze plus many more. If you have started working on a project with SCRalyze and want to continue, you can still find previous software versions, help, and resources on http://scralyze.sourceforge.net.

License

PsPM is provided under the GNU General Public License by the PsPM team, at University College London, University of Bonn, and University of Zurich.

pspm's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pspm's Issues

pspm_extract_segments assertion fails when called by pspm_glm

Summary

Calling pspm_glm function with a model that has multiple sessions and which defines conditions with different number of trials throws an assertion error. The error is at pspm_extract_segments line 501

assert(numel(onset_write_indices_in_cond_and_session) == num_onsets);

Steps to Reproduce

  1. Create 4 session files where each session contains
    2. a condition with 3 trials
    3. a condition with 3 trials
    4. a condition with 6 trials
  2. Create a model variable where
    3. .datafile contains a cell array of the paths to the session files
    4. .timing.onsets refer to some onsets in each signal
  3. Create an options variable with
    4. options.exclude_missing.segment_length = 10.5.
    5. options.cutoff = 25.
  4. Call pspm_glm(model, option).

Expected Results

GLM function returns successfully.

Actual Results

Assertion failure.

(Optional) Possible Cause and Solutions

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: 75e2cb8
  • MATLAB version: 2018b

Create a pspm_find_scanpaths

Feature Description

Feature requested by Yanfang. The goal is to add a new function to PsPM which would extract the scanpath length from pupil data based on the work she has done in her paper. It includes to:

  • Check if pspm_bf_spsrf_box.m and pspm_bf_spsrf_gamma.m work properly (they are needed in the function)
  • Create the new function
  • In pspm_init.m one has to add a new channel type + add a new default.glm parameter.

Variational Bayes Algorithm with the Canonical Response Function

Hello,

I have a question about the use of the Variational Bayes Algorithm (VBA) from Appendix A of the article Dynamic causal modelling of anticipatory skin conductance responses. If I understand correctly, the VBA is used to estimate the parameters for the individual RF of each participant. If a user chooses to use the canonical RF, where those parameters are predetermined, it seems to me that VBA would no longer be required. Does PsPM use VBA with the cRF?

Thanks,
Ben

import_eyelink incorrect blink and saccade periods

Summary

import_eyelink tags wrong samples as blinks or saccades. Therefore, the returned signals are more noisy than they should be.

Steps to Reproduce

  1. Set ep_offset = 0 in import_eyelink.m
  2. Create a small Eyelink .asc file that contains a single blink period in the middle of the data section. Set all the data values in the blink section as to 0.
  3. Import the pupil channel using pspm_get_eyelink
  4. Plot the pupil channel

Expected Results

None of the blink samples should be imported.

Actual Results

Blink period is shifted. Pupil channel includes some of the missing blink values.

(Optional) Possible Cause and Solutions

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: 530e89d
  • MATLAB version: 2018b

Incorrect marker values in Eyelink import when sessions are interrupted

Summary

There are more markers than the number of markers in the actual .asc file when

  • there are session interruptions
  • there is at least one marker in between two sessions

Steps to Reproduce

  1. Get an .asc file with session interruptions and markers between two sessions
  2. Run pspm_import or pspm_get_eyelink

Expected Results

The number of markers should be exactly the same as the number of markers in the .asc file.

Actual Results

There are more markers than the actual number

(Optional) Possible Cause and Solutions

Same marker may be added multiple times.

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: 92252a1
  • MATLAB version: R2018b

Change DCM tutorial data

Summary

This issue was pointed out by a user in #79 . It says that the DCM tutorial data available on sourceforge are still named as src data while they should be named pspm as it is said in the tutorial.

pspm_get_events misses markers that correspond to the first sample row

Summary

pspm_get_events is not able to locate a marker if it occurs on the first sample in a given datafile. This frequently happens with viewpoint data where the marker on the first line indicates that data recording has begun.

Steps to Reproduce

  1. Let a viewpoint datapath be stored in fp. Make sure that fp contains only one marker on the first sample line and no others. This happens quite frequently with viewpoint data.
  2. Run
import{1}.type = 'marker';
options.overwrite = true;
pspm_import(fp, 'viewpoint', import, options);

Expected Results

No error is produced and the data marker channels is imported without any errors/warnings.

Actual Results

A warning from pspm_get_events.m line 75 is issued. lo2hi and hi2lo are empty whereas they both should contain 1, the index of the marker.

(Optional) Possible Cause and Solutions

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: 2a6dda7
  • MATLAB version: R2018b

pspm_ecg2hb crashes on line 463

Summary

pspm_ecg2hb function crashes on line 463 with index out of bounds error on ECG data with outliers. The particular data causes the algorithm to not found any peaks in the initial parts of the run. This in turn leads to the case where there is only one previously found R-peak in pt.set.R variable when the algorithm is at line 463.

Steps to Reproduce

  1. Run pspm_ecg2hb function with heartbeat data that contains many outliers in the beginning.

Expected Results

The algorithm should not crash in case data is very noisy.

Actual Results

The algorithm crashes with index out of bounds error on line 463.

(Optional) Possible Cause and Solutions

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: r642
  • MATLAB version: R2018b

pspm_resp_pp crashes with index out of bounds

Summary

On one input data, pspm_resp_pp reports an error like this: "index exceeds the number of array elements" on line 111. The problem was that, for vector pairs, the last element was 1163; however, for vector indx, it only had 1162 elements

Steps to Reproduce

  1. Run pspm_resp_pp(filepath, 2000, 1, options) with a file containing respiration data and options.systemtype = 'cushion'. Note that this error does not occur in every file, only in some particular ones, so the problem might be an edge case.

Expected Results

pspm_resp_pp should finish successfully.

Actual Results

The function crashes with index out of bounds error.

(Optional) Possible Cause and Solutions

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: r650
  • MATLAB version: R2018b

SPM12 Data Import?

Summary

Dear Dominik
Wondering if it is possible to import SPM12 data directly into PsPM 4.0.2? If not I can import as a matlab array as described in the manual but would appreciate any advice regarding importing the SPM12 event structure into PsPM.

Cheers

-Bill

Technical Info

  • PsPM revision ID:
  • MATLAB version:

Find a way to fix documentation duplication

Feature Description

Our current documentation is split into three pieces:

  1. function docs
  2. matlabbatch docs
  3. user manual

We maintain these three pieces by literally copy-pasting the documentation. Since this is very inefficient and error-prone, a better way to handle this process is required.

pspm_hb2hp do not take into account entered options

Summary

pspm_hb2hp do not take into account entered options such as the upper and lower limits and channel_action. The functions takes always the default parameters.

Steps to Reproduce

  1. % Download the file
    test_hb2hp_data2.zip
  2. option.channel_action = 'abc';
  3. pspm_hb2hp('test_hb2hp_data2.mat',100,[],option);

Expected Results

An error, because there is no such saving option in the pspm_write_channel, it has to be either add or replace instead of abc on the line 2.

Actual Results

The function will produce ans = 1.

(Optional) Possible Cause and Solutions

The cause is that pspm_hb2hp function replaces all the given options by the default ones.

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: 76a3927
  • MATLAB version: R2019b

Too small ITI due to DCM session splitting

Summary

When DCM splits a session into two sessions due to large block of NaNs, last inter trial interval (ITI) of the first splitted session is calculated much shorter than expected ITI value.

Steps to Reproduce

  1. Run pspm_dcm with an input signal containing a long block of NaN values so that session is split into two.

Expected Results

Last ITI value should be similar to the other ITI values calculated for the splitted session.

Actual Results

Last ITI value ends up being much smaller than the other values.

(Optional) Possible Cause and Solutions

The reason for this is that last ITI value is calculated using the length of the data for that session. When the splitting procedure gets rid of NaNs, it decreases the length of data for the session. The specific code is on lines 527-528:

sbs_iti{sbs_id} = [sbs_trlstart{sbs_id}(2:end); ...
    numel(sbs_data{sbs_id, 1})/model.sr] - sbs_trlstop{sbs_id};

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: 5206a0a
  • MATLAB version: 2018b

pspm_filtfilt: Invalid filtering parameters

Summary

When we execute pspm_filtfilt with filtering parameters a and b of dimension 1 (i.e. numbers) one get an error of exceeding index.

Steps to Reproduce

  1. pspm_filtfilt(1,1,[1:10]);

Expected Results

A warning should appear.

Actual Results

The following error occurs:
Index exceeds the number of array elements (1).

(Optional) Possible Cause and Solutions

The cause is the formula we use which is given on lines 12 to 15 of the pspm_filtfilt.m:

% The filter is described by the difference equation:
%
%     y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb)
%                      - a(2)*y(n-1) - ... - a(na+1)*y(n-na)

The solution would be to either modify the formula or to throw a warning. Because of the fact that this function is used a lot the easiest way is to make an assertion and throw a warning.

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: b5ec33a
  • MATLAB version: R2019b

Bug in pspm_get_eyelink function expand_mask

Post by Ulrike Horn:

"

Summary

I am using a very recent commit because the asc eyetracking file import functions are way faster now - thank you for implementing all these great tools! I guess, I noticed a small bug in the get_eyelink function, but maybe you can have a look into that. When the mask for blinks and saccades is expanded by a certain offset, the for loop runs over the indices_to_expand, creates beginning and ending and sets everything in between true. But as the loop is using the whole indices vector instead of single elements, only the first value from each vector is taken and then the loop is left. Furthermore, for the left indices the endidx elements are smaller than the begidx elements, so these should be switched. I hope this wasn't too confusingly explained, sorry!

Steps to Reproduce

using pspm_import with a pupil datafile that contains blinks

Expected Results

pspm_get_eyelink gets called and expands the blink by the given offset using the function expand_mask

Actual Results

only the first blink is expanded

(Optional) Possible Cause and Solutions

see summary above, I changed lines 428ff to:

for ii = 1:numel(indices_to_expand_towards_left)
idx = indices_to_expand_towards_left(ii);
begidx = max(1, idx - offset);
endidx = max(1, idx - 1);
mask(begidx : endidx) = true;
end

for ii = 1: numel(indices_to_expand_towards_right)
idx = indices_to_expand_towards_right(ii);
begidx = min(ndata, idx + 1);
endidx = min(ndata, idx + offset);
mask(begidx : endidx) = true;
end

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: SVN r801
  • MATLAB version: R2017b, 9.3.0.713579, 64bit

"

Allow GLM to use markers distributed across channels

Feature Description

Currently whenever the timeunit of the timing variable is 'markers', pspm_glm uses only one marker channel which can be specified by options.marker_chan_num variable. A user of PsPM suggested that it could be useful to be able to use markers distributed across channels.

pspm_get_viewpoint fail with multiple sessions

Summary

pspm_get_viewpoint crashes with error when given a viewpoint data file containing multiple sessions separated with +,= type of markers.

Steps to Reproduce

  1. Modify a viewpoint datafile to contain multiple sessions using the aforementioned markers
  2. Call pspm_get_viewpoint with appropriate parameters

Expected Results

Function imports the datafile without any errors

Actual Results

Crash due to concatenating arrays of incompatible sizes.

(Optional) Possible Cause and Solutions

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: b25ec0b
  • MATLAB version: R2018b

pspm_convert_unit returns incorrect results to/​from inches

Summary

Results of pspm_convert_unit when called with mixed imperial and metric units are incorrect. In particular, the call pspm_convert_unit(1.0, 'in', 'cm') returns 0.3937 whereas the correct answer should be 2.54 since 1 inch is 2.54 centimeters.

The function returns the correct results when used exclusively with metric units. For example, pspm_convert_unit(1.0, 'm', 'cm') returns 100 as expected.

Steps to Reproduce

  1. Call pspm_convert_unit(1.0, 'in', 'cm')

Expected Results

The result should be 2.54.

Actual Results

The actual result is 0.3937

(Optional) Possible Cause and Solutions

There may be a bug in imperial unit coefficients.

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: r646
  • MATLAB version: R2018b

pspm_extract_segments should not read data from model.datafile field

Feature Description

Reading the data by loading the file at model.datafile field makes the function not compatible with multiple operating systems or different filesystems. Since all the required data should already be stored in GLM or DCM output structures, the whole logic of the function can be simplified significantly while making it more robust.

Wrong default filter settings for GLM modalities & problems with mark

Summary

Tobias Moser: "A bug in the Matlabbatch configuration caused PsPM to load the wrong default filter settings for some GLM modalities. Another bug in the marker editing process in the ECG editor caused wrong indexing in manual mode. Both bugs are fixed in versions >= 3.1.1." See https://sourceforge.net/p/pspm/discussion/bugs/thread/78373dfa

Steps to Reproduce

Expected Results

Actual Results

(Optional) Possible Cause and Solutions

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID:
  • MATLAB version:

pspm_prepdata returns all NaNs when input signal has NaN value(s)

Summary

pspm_prepdata cannot gracefully handle signals with NaN value(s). The returned signal contains all NaN values.

Steps to Reproduce

  1. Run the below code:
filt.sr = 500;
filt.lpfreq = 20;
filt.lporder = 1;
filt.hpfreq = 5;
filt.hporder = 1;
filt.direction = 'uni';
filt.down = 200;
data = sin(1:10000);
data(10) = NaN;
[sts, outdata, newsr] = pspm_prepdata(data, filt);

Expected Results

The function should somehow inputs with NaN values, or at least should give a warning about this issue.

Actual Results

The function completes with success status, but outdata contains only NaN values.

(Optional) Possible Cause and Solutions

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: ea9490b
  • MATLAB version: R2018b

import_viewpoint creates a new session with CS+ marker

Summary

import_viewpoint creates a new session if a marker contains + somewhere. Therefore a CS+ marker causes a session split.

Steps to Reproduce

  1. Create a viewpoint datafile containing a CS+ marker and only one session
  2. Run import_viewpoint

Expected Results

Only one session is returned

Actual Results

Multiple sessions are returned

(Optional) Possible Cause and Solutions

Add an extra check to ensure a marker contains only +=, characters.

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: b25ec0b
  • MATLAB version: R2018b

pspm_get_events should allow choosing rising, middle or falling edge of a marker

Feature Description

Currently, pspm_get_events returns the middle of a marker impulse by default. However, this behaviour is undesirable in many situations where tagging the marker by the rising or the falling edge make more sense. Therefore, we should add an option to pspm_get_events so that the user can choose whether they want

  1. rising edge
  2. middle
  3. falling edge

of a marker impulse.

In addition, this option should be cascaded all the way to the top user-level functions that at some point use pspm_get_events. Therefore, the main tasks are

  • Modify pspm_get_events to allow choosing the marker tag
  • Find top-level user space functions that depend on this functionality
  • Include the aforementioned option in these functions' interfaces.

Increase available y-axis units in pspm_display

Feature Description

The y-axis name and units are set in pspm_display on lines 773-786 with the following block of code. For now it treats only few cases. Thus, this list should be increased to the most used data types. (Dominik's request)

wv_chanid = handles.prop.wavechans(handles.prop.idwave);
unit = deblank(handles.data{wv_chanid}.header.units);
if strcmp(handles.prop.wave,'ecg')
   ylabel([' Amplitude [',unit,'] '],'Fontsize',14);
elseif strcmp(handles.prop.wave,'scr')
   ylabel([' Amplitude [',unit,'] '],'Fontsize',14)
elseif strcmp(handles.prop.wave,'emg')
   ylabel([' Amplitude [',unit,'] '],'Fontsize',14)
elseif strcmp(handles.prop.wave,'hp')
   ylabel(' Interpolated IBI [ms] ','Fontsize',14)
elseif strcmp(handles.prop.wave,'pupil')
   ylabel(' size in arbitrary units ','Fontsize',14)
else ylabel([' unknown unit [',unit,'] '],'Fontsize',14)
end 

Number of marker names and marker onsets mismatch in Eyelink import

Summary

I am not sure yet if this is a real bug but I noticed that the number of marker names and number of marker onsets mismatch after importing an eyelink asc file.

Steps to Reproduce

  1. Import an Eyelink .asc file containing some markers using pspm_get_eyelink function
  2. Eyelink data file should contain markers with the following properties:
  • there is at least one marker whose timestamp is outside the timestamp range of the data samples
  • there are at least two markers whose timestamps are exactly the same

Expected Results

I expected that marker.values marker.names and data should have equal sizes.

Actual Results

struct with fields:
data: [2858×1 double]
markerinfo: [1×1 struct]
header: [1×1 struct]

        data{2}.markerinfo
        ans =
        struct with fields:
        name: {2860×1 cell}
        value: [2860×1 double]

(Optional) Possible Cause and Solutions

After comparing the imports from versions 4.0.2 with 4.2.0 I can see that that the first and last marker names (4.2.0) are not included in the cell arrays of marker names imported by the older pspm version.
I couldn't find anything in the pspm_trim.m file that takes into account these size differences. My guess is that it has something to do with the import_eyelink.m function and that some irrelevant eyelink messages are saved as marker names. However, I have not had the time to verify this with a different data set.

A Possible Workaround Suggested in the original issue

Please let me know if this is a valid work around or if I am seeing a bug where there is none.

PSPM v4.2.0
import_eyelink.m
line 259

% construct markers
markers.markers = false(size(dataraw, 1), 1);
markers.times = [];
markers.names = {};
for idx = msg_indices
    msgline = messages{idx};
    parts = split(msgline);
    time = str2num(parts{2});
    markers.markers(bsearch(timecol, time)) = true;
    markers.times(end + 1, 1) = time;
    markers.names{end + 1, 1} = cell2mat(join(parts(3:end), ' '));
end

My work around

% construct markers
markers.markers = false(size(dataraw, 1), 1);
markers.times = [];
markers.names = {};
for idx = msg_indices
    msgline = messages{idx};
    parts = split(msgline);
    time = str2num(parts{2});
    % I have several cases where 2 markers times are identical although with
    % different names. Identical times become problematic in the next
    % step when we use them as index. This is my workaround so far...
    if ~isempty(markers.times) && time == markers.times(end)
        time = time+1;
    end
    % I am using ismeber instead of index = bsearch(x,var) here because
    % if the var that we are looking for is not included in the data vector
    % then index becomes max(x).
    i_search = find(ismember(timecol, time));
    if ~isempty(i_search)
        markers.markers(i_search) = true;
        markers.times(end + 1, 1) = time;
        markers.names{end + 1, 1} = cell2mat(join(parts(3:end), ' '));
    else
        %dont save time and name
    end
end

"""

Technical Info

Find out minimum MATLAB version

Feature Description

Find out the minimum MATLAB version that can run support whole PsPM functionality. Current development is being done on R2018b, but we should be able to support much earlier version such as 2013.

Multiple sessions GLM and Design matrix

Summary

Tobias Moser: "A bug causes scr_glm to concatenate event onsets for multiple sessions incorrectly. The problem can be observed in the 'design matrix' when onsets appear only at the begining. The bug was introduced in SCRalyze 2.1.8.2 and fixed in PsPM 3.0.2." See https://sourceforge.net/p/pspm/discussion/bugs/thread/55403467

Steps to Reproduce

Expected Results

Actual Results

(Optional) Possible Cause and Solutions

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID:
  • MATLAB version:

pspm_version crashes when MATLAB is invoked with -nojvm

Summary

pspm_version function crashes when MATLAB is invoked with -nojvm option. Below is the stacktrace:

Error using urlreadwrite (line 8)
urlread is not supported because:
Java is not currently available.
Error in urlread (line 47)
[s,status] = urlreadwrite(mfilename,catchErrors,url,varargin{:});

Steps to Reproduce

  1. Start MATLAB with -nojvm -nodesktop -nobatch options
  2. Run `pspm_version('check')

Expected Results

Function returns status 1 and the latest PsPM version obtained from website

Actual Results

Crash due to lack of JRE

(Optional) Possible Cause and Solutions

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: ea9490b
  • MATLAB version: R2018b

Graphing the Canonical Response Function

Hello,

I am attempting to graph the canonical response function described in Appendix A of the article Modelling event-related skin conductance responses. My MATLAB code to graph it is as follows:

syms x;
syms N(t);
syms E(t);
N(t) = (1/sqrt(2*pi*0.7013))*exp((-(t-3.0745)^2)/(2*(0.7013^2)));
E(t) = exp(-0.3176*t) + exp(-0.0708*t);
CRF = int(N(t-x)*E(x),x,-inf,inf);

I've attached the resulting graph to this post. It has the tail that I expected but does not have a sharp rise at the beginning. Can you confirm that I'm following the equation from Appendix A correctly?

Thanks,
Ben
CRF

ECG with NaN values crashes pspm_display

Summary

pspm_display crashes when trying to plot ECG signal that contains NaN values together with marker event channel and extra event option. The stacktrace is below:

Error using matlab.graphics.axis.decorator.Baseline/set
Error setting property 'BaseValue' of class 'Baseline':
Value should be a valid number
Error in pspm_display>pp_plot (line 778)
                set(hbase,'BaseValue',base(2),'Visible','off');
                Error in pspm_display>push_plot_Callback
                (line 968)
pp_plot(handles);
Error in gui_mainfcn (line 95)
        feval(varargin{:});
Error in pspm_display (line 44)
    gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)pspm_display('push_plot_Callback',hObject,eventdata,guidata(hObject))

Steps to Reproduce

  1. Run pspm_display
  2. Open a PsPM datafile containing an ECG channel that has some NaN values
  3. Choose ecg, marker and extra
  4. Click plot

Expected Results

The signal should be plotted on the panel at the top

Actual Results

The function crashes

(Optional) Possible Cause and Solutions

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: 513df72
  • MATLAB version: R2018b

Estimating inputs to the pupil model

Feature Description

I'm relaying a feature request from @dominikbach: the feature in question is estimating inputs of the pupil response model.
The idea is to enable analyses similar to ones from the Korn & Bach (2016) paper (in particular, analyses leading to figures 9, 10, 11).

The assumption here is that the pupil can be modeled as an LTI system, with the exact response function depending on whether pupil dilations or constrictions are modeled (this is implemented in PsPM functions pspm_bf_ldrf_gm.m and pspm_bf_lcrf_gm.m respectively).
Additionally, the method assumes the functional form of the input signal (in the paper, this is a gamma pdf), and the parameters of this input function are optimized such that the squared error between the prediction (convolution of the input and the LTI response function) and the observed data is minimized.
The paper doesn't explicitly mention which optimization method was used, but I think it might have been fminsearch (other analyses in the paper use this method).

The function should have a similar API as pspm_glm, and it should support condition-wise model fitting.
Importantly (and differently from the GLM), all the responses of a condition should be averaged before the input is estimated.

To start work on this, you would need some pupil size data with trial-wise markers.
I believe Dominik will get in touch with Christoph about getting the data from the paper, but in the meantime, you can use any pupil size data that has markers.

bug in 'review model' functionality

Summary

When reviewing a model, one has the possibility to plot the data and the according events (i.e., Predicted & observed). In Version v.4.0.2 the plot won't show all the events, if there exists more than 7 conditions.
https://sourceforge.net/p/pspm/discussion/bugs/thread/c505516b0b/

Steps to Reproduce

  1. check if line 153 (for older revisions than 6667, line 146) in pspm_rev_glm contains: m = floor(j/cl);
  2. Try to review a GLM model which has more than 7 conditions

Expected Results

Each condition should be displayed and be marked with a color.

Actual Results

You will see that not all conditions are shown.

(Optional) Possible Cause and Solutions

The problem occurs when assigning different colors to the events for the plot. In some cases m becomes 0 and then an index out of bounds error occurs.
The solution is to replace m = floor(j/cl);' in line 153 (for older revisions than 6667, line 146) to m = floor((j-0.1)/cl);

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: 606, v.4.0.2
  • MATLAB version: -

call of pspm_butter & pspm_prepdata failed

Hi there,

I am following the GLM for SCR tutorial: Appraisal data, but run in to this issue when trying to import data:

"23-Dec-2019 19:48:58 - Running job #2

23-Dec-2019 19:48:58 - Running 'Import'

Pulse data was converted to waveform with a sampling rate of 5000.00 Hz, to allow 10-fold oversampling.
Warning: call of pspm_butter failed

In pspm_prepdata (line 102)
In pspm_pulse_convert (line 75)
In pspm_get_spike (line 82)
In pspm_import (line 199)
In pspm_cfg_run_import (line 97)
In cfg_run_cm (line 29)
In cfg_util>local_runcj (line 1708)
In cfg_util (line 968)
In cfg_ui>MenuFileRun_Callback (line 703)
In gui_mainfcn (line 95)
In cfg_ui (line 53)
Warning: call of pspm_prepdata failed
In pspm_pulse_convert (line 77)
In pspm_get_spike (line 82)
In pspm_import (line 199)
In pspm_cfg_run_import (line 97)
In cfg_run_cm (line 29)
In cfg_util>local_runcj (line 1708)
In cfg_util (line 968)
In cfg_ui>MenuFileRun_Callback (line 703)
In gui_mainfcn (line 95)
In cfg_ui (line 53)
done.
23-Dec-2019 19:49:02 - Done 'Import'
23-Dec-2019 19:49:02 - Done"

Although this actually creates the file "pspm_trsp_1_25.mat", I seem to get errors when trying to specify the first-level GLM, which does not create "glm_25.mat":

"------------------------------------------------------------------------
23-Dec-2019 19:55:01 - Running job #4

23-Dec-2019 19:55:01 - Running 'GLM for SCR'
Computing GLM: /Users/kash/Downloads/Tutorial_data_GLM/glm_25.mat ...
Getting data ....
Preparing & inverting model ... Warning: call of pspm_butter failed

In pspm_prepdata (line 102)
In pspm_glm (line 484)
In pspm_cfg_run_glm_scr (line 38)
In cfg_run_cm (line 29)
In cfg_util>local_runcj (line 1708)
In cfg_util (line 968)
In cfg_ui>MenuFileRun_Callback (line 703)
In gui_mainfcn (line 95)
In cfg_ui (line 53)
Warning: Failed to filter data
In pspm_glm (line 485)
In pspm_cfg_run_glm_scr (line 38)
In cfg_run_cm (line 29)
In cfg_util>local_runcj (line 1708)
In cfg_util (line 968)
In cfg_ui>MenuFileRun_Callback (line 703)
In gui_mainfcn (line 95)
In cfg_ui (line 53)
23-Dec-2019 19:55:02 - Done 'GLM for SCR'
23-Dec-2019 19:55:02 - Done"

Any ideas why this is happening?

Attaching all the batch files in case I have made an obvious mistake.

batch-files.zip

pspm_hb2hp crashes when there is not enough heartbeats

Summary

pspm_hb2hp crashes when there is no heartbeat left after lower and upper bound filtering of the heartbeat periods.

Steps to Reproduce

  1. Run pspm_hb2hp on a heartbeat signal with options.limit.lower and options.limit.upper values set very strictly so that no heartbeat remains after filtering.

Expected Results

The function should return a timeseries of NaN values

Actual Results

Crash

(Optional) Possible Cause and Solutions

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: 4d0cf4d
  • MATLAB version: R2018b

pspm_dcm excludes all of reinforced CS+ trials

Summary

When pspm_dcm is run on an experiment with 40 trials, 20 of which are reinforced CS+ trials, all the reinforced CS+ trials are excluded from the analysis. All these reinforced CS+ trials coincide with signal segments that should be excluded by setting model.missing. However, most of the model.missing epochs are less than model.substhresh; therefore, these segments should be interpolated rather than completely ignored.

Steps to Reproduce

  1. Run pspm_dcm on such an experiment while setting model.missing epochs in such a way that they coincide with excluded trials while being short enough.

Expected Results

pspm_dcm analyzes all input trials

Actual Results

The sessions are split into many small subsessions and many trials are ignored, even though all the model.missing epochs are shorter than session splitting threshold.

(Optional) Possible Cause and Solutions

In pspm_dcm documentation, it is stated that model.substhresh is ignored if model.missing is set. However, this causes a bug like the current one to appear.

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: 0332221
  • MATLAB version: R2018b

Importing .acq files returns incorrect data

Summary

Importing .acq files using the batch system returns data that is not identical to the original data. In particular, by following the below steps, we get data that is not identical to the original data itself:

Steps to Reproduce

  1. We use a .acq file obtained from Acqknowledge 3.0 with gain = 20 uS/V and Gmax = 200uS. In addition, we need .mat file obtained by using the export functionality. We call these two files raw_acq and raw_mat, respectively.
  2. We use the following batch job code to import raw_acq into PsPM format:
matlabbatch{1}.pspm{1}.prep{1}.import.datatype.acq.datafile = {'raw_acq'};
matlabbatch{1}.pspm{1}.prep{1}.import.datatype.acq.importtype{1}.scr.chan_nr.chan_nr_spec = 1;
matlabbatch{1}.pspm{1}.prep{1}.import.datatype.acq.importtype{1}.scr.scr_transfer.none = true;
matlabbatch{1}.pspm{1}.prep{1}.import.overwrite = false;

Similarly, we use the following code to import raw_mat into PsPM format:

matlabbatch{1}.pspm{1}.prep{1}.import.datatype.mat.datafile = {'raw_mat'};
matlabbatch{1}.pspm{1}.prep{1}.import.datatype.mat.importtype{1}.scr.chan_nr.chan_nr_spec = 1;
matlabbatch{1}.pspm{1}.prep{1}.import.datatype.mat.importtype{1}.scr.sample_rate = 2000;
matlabbatch{1}.pspm{1}.prep{1}.import.datatype.mat.importtype{1}.scr.scr_transfer.none = true;
matlabbatch{1}.pspm{1}.prep{1}.import.overwrite = false;

We call the PsPM files obtained using these two steps batch_acq and batch_mat, respectively.
3. We use the following MATLAB script to import raw_acq into PsPM format bypassing the batch system:

import = struct( ...
    'type', 'scr', ...
    'channel', 1, ...
    'transfer', 'none' ...
);
options.overwrite = false;
pspm_acq_file = pspm_import('raw_acq', 'acq', import, options);

Similarly, we use the following code to import raw_mat into PsPM format bypassing the batch system:

import = struct( ...
    'type', 'scr', ...
    'channel', 1, ...
    'transfer', 'none', ...
    'sr', 2000 ...
);
options.overwrite = false;
pspm_mat_file = pspm_import('raw_mat', 'mat', import, options);

We call the PsPM files obtained using these two steps cmd_acq and cmd_mat, respectively.
4. The data stored in batch_mat is identical to the data stored in raw_mat. However, the data stored in batch_acq differs from these two.
5. The data stored in cmd_mat, cmd_acq and raw_mat are all identical. The data stored in cmd_acq is identical to batch_acq and is incorrect.

Expected Results

The data read in two different ways should produce the same results.

Actual Results

Data read using pspm_get_acq differs from the Acqknowledge exported .mat file.

(Optional) Possible Cause and Solutions

Since all the results obtained using PsPM functions directly are the same and since the export function of Acqknowledge works correctly, there must be a bug when importing .acq files using the batch system. The bug must be in acq reading part of PsPM.

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: r647
  • MATLAB version: R2018b

bug in 'artefact removal ' functionality

Summary

The functionality to remove artefacts of specific channels does not work properly . The function pspm_pp results in changes only in the first channel instead of the chosen one.
See https://sourceforge.net/p/pspm/discussion/bugs/thread/17bcaee6/ .

Steps to Reproduce

Expected Results

Filtering of all passed channels.

Actual Results

Filtering of only the first channel.

(Optional) Possible Cause and Solutions

The bug is located in the for-loops where the index of the chosen channels must be used instead of the loop counter to access the data.

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: before 597. v.4.0.2
  • MATLAB version:-

pspm_get_viewpoint returns +,=,+ lines in the marker list

Summary

pspm_get_viewpoint returns +,=,+ lines, which denote the beginning of data recording, in the marker list. Since these are not important for researchers, these lines should be filtered out of the marker list.

Steps to Reproduce

  1. Import the marker channel from a viewpoint file via
import{1}.type = 'marker';
[sts, out, srcinfo] = pspm_get_viewpoint(datafile_path, import);

Expected Results

Marker channel contains only the markers entered by the user.

Actual Results

Marker channel contains +,=,+ lines, as well.

(Optional) Possible Cause and Solutions

We need to filter markers that denote the beginning of data recording out of the marker list. However, this should be done intelligently so that no actual marker is filtered out.

Currently import_viewpoint function which handles the datafile reading part is doing its part correctly by returning all the markers in the file. However, pspm_get_viewpoint should perform this filtering so that the returned marker channel conforms to PsPM standard.

(Optional) Screenshots if Graphical User Interface is Used

Technical Info

  • PsPM revision ID: 0332221
  • MATLAB version: R2018b

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.