Test and Measurement Forum

Unable to read filtered picoscope data saved as .mat file

Forum for discussing PicoScope version 6 (non-automotive version)

Unable to read filtered picoscope data saved as .mat file

Postby Tom1 » Sun Jul 03, 2016 1:28 pm

Hello,

I am using Picoscope 6 for data acquisition and also use the software to filter the data after the measurements are taken. In order to do further analysis, I would like to transfer this filtered data to a .mat file and load this into Matlab. Unfortunately Matlab gives an error stating it cannot read the file. Remarkably the non-filtered data files generate no error. In the past I have worked around this by saving the data as a .csv files and load those files into Matlab, but the sample rate of the current measurements is too high to save the entire waveform as a .csv file.

Is there a way to solve this problem?

With kind regards,
Tom
Tom1
Newbie
 
Posts: 0
Joined: Sun Jul 03, 2016 1:13 pm

Re: Unable to read filtered picoscope data saved as .mat fil

Postby Hitesh » Tue Jul 19, 2016 12:33 pm

Hi Tom,

Which version of PicoScope 6 are you using?

Have you tried the PicoScope 6.12 Beta version.

It might be useful to see a psdata file with the filtered data in order to see your settings.

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Unable to read filtered picoscope data saved as .mat fil

Postby biomedikal » Wed Sep 07, 2016 6:47 pm

I am facing the same problem with picoscope 6, I am not able to read the filtered data, while I am able to process the unfiltered data using the matlab

Any solutions to this, is this matlab problem or picoscope problem?
biomedikal
Newbie
 
Posts: 0
Joined: Wed Sep 07, 2016 6:45 pm

Re: Unable to read filtered picoscope data saved as .mat fil

Postby Hitesh » Thu Sep 08, 2016 8:33 am

Hi biomedikal,

This is a known issue with export to .mat file format from the PicoScope 6 software.

The issue has been fixed and should be available via the next release of the software.

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Unable to read filtered picoscope data saved as .mat fil

Postby biomedikal » Tue Sep 13, 2016 6:39 pm

When are we getting next release of software?
biomedikal
Newbie
 
Posts: 0
Joined: Wed Sep 07, 2016 6:45 pm

Re: Unable to read filtered picoscope data saved as .mat fil

Postby Hitesh » Wed Sep 14, 2016 12:44 pm

Hi biomedikal,

No definite timescale at present but hopefully in a few weeks.

You may wish to enable the prompt for updates via the Tools -> Preferences dialog in order to be notified of a release if your PC is connected to the Internet.

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Unable to read filtered picoscope data saved as .mat fil

Postby ivizot » Fri Nov 04, 2016 8:50 am

Hey all,

finally I found a way to fix mat files in Matlab.

Here is the code - just run it into your directory with corrupted files, it will put fixed files in "FIXED mat" directory.

Hope that would help someone...

Code: Select all
%% PICOSCOPE mat files are corrupted
% Copyright Ivan Izotov, IAP RAS, 2016
clearvars;

ddin='.';
ddout='FIXED mat';
if ~exist(fullfile(ddin,ddout),'dir')
    mkdir(ddin,ddout);
end
fls=dir(fullfile(ddin,'*.mat'));

fixed_count=0;
for j=1:numel(fls)
    fn=fullfile(ddin,fls(j).name);
    F=fopen(fn);
    [pathstr,name,ext] = fileparts(fn);
    Fout=fullfile(ddin,ddout,fls(j).name);
    file_ok=1;
    i=1;
    V='''ORIGINAL_FILE''';
    ORIGINAL_FILE=fn;
    while ~feof(F)
        h5=fread(F,5,'int32');
        %{
    h5(1) - type; 0->double, 10->single, 20->integer
    h5(2) - length;
    h5(3) == 1;
    h5(4) == 0;
    h5(5) == length of name including \0 character;
        %}
        if length(h5) < 5
            fprintf('Header corrupted at variable #%d.\n', i);
            file_ok=0;
            break;
        end
        if h5(2) == 0
            fprintf('Found bad 0-byte size at variable #%d.\n', i);
            file_ok=0;
            break;
        end
        data=fread(F,h5(5),'*char')';
        var_name=data(1:end-1);
       
        switch h5(1)
            case 0
                data_type='double';
            case 10
                data_type='single';
            case 20
                data_type='int';
            otherwise
                fprintf('Unknown var type at variable #%d.\n', i);
                file_ok=0;
                break
        end
       
        data=fread(F,h5(2),data_type);
        eval([var_name '=data;']);
       
%         %% fixing header
%         h5(2)=length(data);
        V=[V ',''' var_name ''''];
       
        i=i+1;
    end
   
    if feof(F)
        fprintf('%s file FIXED.\n',fls(j).name);
        fixed_count=fixed_count+1;
        %% writing fixed file
        eval(['save(Fout,' V ',''-mat'');']);
        eval(['clearvars(' V ');']);
    else
        fprintf('%s file ERROR',fls(j).name);
    end
   
    fclose(F);
end

fprintf('%d files out of %d were fixed.',fixed_count,numel(fls));
clearvars;
ivizot
Newbie
 
Posts: 0
Joined: Fri Nov 04, 2016 8:46 am


Return to PicoScope 6 for Windows

Who is online

Users browsing this forum: No registered users and 0 guests