Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/ViCCo-Group/THINGS-data
02 March 2023, 06:01:16 UTC
  • Code
  • Branches (2)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    • refs/heads/oli
    No releases to show
  • 103c132
  • /
  • MEG
  • /
  • step3c_validation_pairwise_decoding_mne_to_cosmo.m
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge Iframe embedding
swh:1:cnt:28a8ecaab16c063248ae76ab9e93f4e3a52a0cfb
origin badgedirectory badge Iframe embedding
swh:1:dir:000e91241105269711aba9dceee5d5fb752db093
origin badgerevision badge
swh:1:rev:2d95c15d3a2cc5984ffd4a9a2c4ad3496847ca9d
origin badgesnapshot badge
swh:1:snp:4c1e0fab18d6e2d8038137bab93d0cb9721ba358

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 2d95c15d3a2cc5984ffd4a9a2c4ad3496847ca9d authored by Oliver Contier on 28 February 2023, 15:15:53 UTC
fixed howtocite
Tip revision: 2d95c15
step3c_validation_pairwise_decoding_mne_to_cosmo.m
function step3c_validation_pairwise_decoding_mne_to_cosmo(bids_dir, toolbox_dir, varargin)
    %% Function that takes preprocessed MNE data and transforms it to a matlab-cosmo script
    % Note: this script requires the MNE-matlab & cosmomvpa toolboxes 
    %
    % @ Lina Teichmann, 2022
    %
    % Usage:
    % step3c_validation_pairwise_decoding_mne_to_cosmo(bids_dir, ...)
    %
    % Inputs:
    %   bids_dir        path to the bids root folder 
    %   toolbox_dir         path to toolbox folder containtining CoSMoMVPA
    %
    % Returns:
    %   ds              Cosmo data struct, saved in BIDS/derivatives/preprocessed folder
    % 
    

    %% parameters    
    preprocdir      = [bids_dir '/derivatives/preprocessed/'];

    addpath(genpath([toolbox_dir '/mne-matlab']))
    addpath(genpath([toolbox_dir '/CoSMoMVPA']))
    
    n_participants  = 4;

    %% loop
    for p=1:n_participants
        tic
        tmp_filenames = dir([preprocdir '/preprocessed_P' num2str(p) '-epo*.fif']);  
        n1 = {tmp_filenames.name};
        [~,I] = sort(cellfun(@length,n1));
        all_files = n1(I);
        
        %sanity check
        disp('stacking files in this order: ')
        for i = 1:length(all_files); disp(all_files{i}); end
        
        for f = 1:length(all_files)
            epo{f} = make_ds(fiff_read_epochs([preprocdir filesep cell2mat(all_files(f))]));
        end

        sa_tab = readtable([bids_dir '/sourcedata/sample_attributes_P' num2str(p) '.csv']);
        sa = table2struct(sa_tab,'toscalar',1);

        ds = cosmo_stack(epo);
        ds.sa = sa;
        
        save([preprocdir '/P' num2str(p) '_cosmofile.mat'],'ds','-v7.3')
        fprintf('Saving finished in %i seconds\n',ceil(toc))

    end



end


%% helper function
function ds = make_ds(part)
    data = reshape(part.data,[size(part.data,1),size(part.data,2)*size(part.data,3)]);
    chan = repmat(1:size(part.data,2),1,size(part.data,3));
    time = repelem(1:size(part.data,3),1,size(part.data,2));

    ds = struct();
    ds.samples = data;
    ds.a.fdim.labels = [{'chan'};{'time'}];
    ds.a.fdim.values = [{1:size(part.data,2)};{part.times}];
    ds.fa.chan = chan; 
    ds.fa.time = time;   
end

    

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API