Menu

marker matlab file

Help
2018-11-05
2018-11-21
  • Claudia Massaccesi

    Hi,
    I am new to pspm and I have some questions.
    I am working with ECG data that I imported in pspm as matlab files.
    I have one channel with the ecg data and one channel with markers (a vector of all 0 and 10 or 20 as markers).
    When I plot my data with pspm I can easily see my markers but when I look inside the imported data or I use the "extract event marker info ", the cell "markerinfo.value" is zero for both markers (but the timestamps are correct). What is wrong?

    Moreover, is it possible to trim data in other ways from the one listed (from start of the file, from marker), for example from the end of the recording instead of the start?

    Thank you

    Claudia

     
  • Dominik Bach

    Dominik Bach - 2018-11-07

    Hi Claudia

    thanks for posting. I'll look into it. Perhaps you could send a sample pre-import file?

    Dominik

     
  • Claudia Massaccesi

    Yes of course!
    I am sure I put something wrong but I am new to this toolbox and I cannot find what is the problem.
    My original files where in .Poly5 format so I readjusted them in single .mat files per subject.
    Attached you can find one of this .mat files. The first column contained ECG data, the second one is timepoints and the third one is the marker channel.

    Thank you for the help!

    Claudia

     

    Last edit: Claudia Massaccesi 2018-11-09
    • Laure Ciernik

      Laure Ciernik - 2018-11-14

      Hi Claudia
      To the first error: I think there occurs an error while the import. I used your pre-import data and saw that the markerinfo is set to the wrong values. I fixed the error on the SVN version. You can just download it from sourceforge and check if it works now for all your subjects.
      To the question about the trim possibilities: There are only these ways listed to trim the data. At the moment I'm working at a functionality such that you can chose to trim from the first marker having a value xxx to the first marker having a value yyy, but your suggested way is not possible yet.
      Best,
      Laure

       
      • Claudia Massaccesi

        Dear Laure,
        thank you for your reply, but I did not get what I have to download to see if it is working with my participants :D
        Sorry!
        Claudia

         
        • Laure Ciernik

          Laure Ciernik - 2018-11-21

          Dear Claudia

          You have to download the new version of pspm_get_events.m (the script which contained the bug) and update this file in your folder. You can find the new version on sourceforge by clicking on "Code" -> "trunk" and look in this folder for a file called "pspm_get_events.m". By clicking on this file, you will get you to a page, where you can download this specific file.
          I hope this helps a little.

          • Laure
           
  • Claudia Massaccesi

    UPDATE: I solved this issue like this:
    (I guess it is not possible to do it with matlabbatch from the command line..)

    filename = [Sourcedir,'data_ID_', num2str(sub), '_', num2str(n_rec), '.mat'];
    options = struct('overwrite', false);
    import = {struct('type', 'ecg', 'channel', 1, 'sr', 1024),...
    struct('type', 'custom', 'channel', 2, 'sr', 1024),...
    struct('type', 'marker', 'channel', 3, 'sr', 1024)};
    imported_file = pspm_import(filename, 'mat', import, options);


    I actually have also another problem. I am used to spm and I usually set up a batch from the GUI and then I change all the field I need to change for every participants in a loop. I don't know whether this is possible with pspm too.

    This is my script to import data:

    clear all;

    % Add pspm path
    pspm_path = 'C:\toolbox\';
    addpath ( pspm_path );

    %% IMPORT AS PSPM.MAT

    Sourcedir_batches = 'X:\Clau\State-dependet_opioid_modulation\ANALYZED\ANALYZED_HR_prova\HR_finaldata\batch\';
    Sourcedir = 'X:\Clau\State-dependet_opioid_modulation\ANALYZED\ANALYZED_HR_prova\HR_finaldata\';

    subjects = 1:45;
    rec = 1:6;

    for i = 1:length(subjects)
    sub = subjects(i);
    for n = 1:length(rec)
    n_rec = rec(n);

        % initialise PsPM
        pspm_init
        pspm_jobman ('initcfg');
    
        % load batch
        %this batch import 3 channels: 1 = ecg, 2 = time (custom), 3 = marker; sampling rate = 1024;   overwrite = no
    
        load([Sourcedir_batches, 'mat2pspm.mat']);
    
        % empty batch
        matlabbatch{1,1}.pspm{1,1}.prep{1,1}.import.datatype.mat.datafile = [];
        % fill batch
        filename = [Sourcedir,'data_ID_', num2str(sub), '_', num2str(n_rec), '.mat'];
        matlabbatch{1,1}.pspm{1,1}.prep{1,1}.import.datatype.mat.datafile = filename;
    
        % run batch
        pspm_jobman('run', matlabbatch);
    
    end
    

    end

    Even if the batch is filled correctly, I always get this error:

    No executable modules, but still unresolved dependencies or incomplete module inputs.
    The following modules did not run:
    Skipped: Import
    If the problem can be fixed without modifying the job, the computation can be resumed by running
    cfg_util('cont',1)
    from the MATLAB command line.

    Error using MATLABbatch system
    Job execution failed. The full log of this run can be found in MATLAB command window, starting with the lines (look for the line
    showing the exact #job as displayed in this error message)

    I tried also like this:
    filename = 'X:\Clau\State-dependet_opioid_modulation\ANALYZED\ANALYZED_HR_prova\HR_finaldata\data_ID_1_2.mat';
    fs = 1024

    mat.datafile = filename;
    mat.importtype{1}.ecg.chan_nr.chan_nr_spec = 1;
    mat.importtype{1}.ecg.sample_rate = fs;
    mat.importtype{2}.custom.chan_nr.chan_nr_spec = 2;
    mat.importtype{2}.custom.sample_rate = fs;
    mat.importtype{3}.marker.chan_nr.chan_nr_spec = 3;
    mat.importtype{3}.marker.sample_rate = fs;
    matlabbatch{1}.pspm{1}.prep{1}.import.datatype.mat = mat;
    matlabbatch{1}.pspm{1}.prep{1}.import.overwrite = false ;

    % run batch
    pspm_jobman('initcfg');
    pspm_jobman('run', matlabbatch );

    But I got exaclty the same error...

    Sorry for the long post.
    Thank you again

    Claudia

     

    Last edit: Claudia Massaccesi 2018-11-12
  • Dominik Bach

    Dominik Bach - 2018-11-14

    Hi Claudia

    to troubleshoot the matlabbatch problem: can you save the variable matlabbatch in mat file, and try to open it in the matlabbatch GUI? Ideally this will show up that/where something is missing, or if it is a code bug.

    Best
    Dominik

     
    • Claudia Massaccesi

      Thank you a lot I will definitely do it!
      Best,
      Claudia

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.