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

Raw File Download

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
content badge Iframe embedding
swh:1:cnt:abb5fdaa3fc53cad72e58e64765b46174ddc02ae

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
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
function step3d_validation_pairwise_decoding200(bids_dir, toolbox_dir, participant, blocknr, n_blocks)

    %% Function to run pairwise decoding analysis for the 200 repeat stimuli
    %
    % @ Lina Teichmann, 2022
    %
    % Usage:
    % step3d_validation_pairwise_decoding200(bids_dir,participant, ...)
    %
    % Inputs:
    %   bids_dir        path to the bids root folder 
    %   toolbox_dir         path to toolbox folder containtining CoSMoMVPA
    %   participant     participant number
    %   blocknr         number of the chunk you want to run this analysis for 
    %   n_blocks        how many blocks you want to run this analysis in (this is to make it faster by running stuff in parallel)
    %
    % Returns:
    %   decoding_acc    file that has the decoding accuracy for each decoding block ('PX_pairwise)decoding_200_blockX.mat')
    %   decoding_pairs  file that contains which pairwise comparisons were run so it can be stacked back together ('PX_pairwise)decoding_200_blockX_pairs.mat')
    
    
    %% folders
    preprocdir      = [bids_dir '/derivatives/preprocessed/'];
    res_dir         = [bids_dir '/derivatives/output/']; 
    
    addpath(genpath([toolbox_dir '/CoSMoMVPA']))

    load([preprocdir '/P' num2str(participant) '_cosmofile.mat'],'ds');
    
    % make a pairwise decoding folder if it does not exist
    if ~exist([res_dir '/pairwise_decoding'], 'dir')
        mkdir([res_dir '/pairwise_decoding'])
    end
    outfn = [res_dir '/pairwise_decoding/P' num2str(participant) '_pairwise_decoding_200_block' num2str(blocknr) '.mat'];
    outfn_pairs = [res_dir '/pairwise_decoding/P' num2str(participant) '_pairwise_decoding_200_block' num2str(blocknr) '_pairs.mat'];
    
    
    %% pairwise decoding
    ds = cosmo_slice(ds,strcmp(ds.sa.trial_type,'test'));
    ds.sa.targets = ds.sa.things_category_nr;
    ds.sa.chunks = ds.sa.session_nr;
    all_combinations = combnk(unique(ds.sa.targets),2);

    % split into blocks
    step = ceil(length(all_combinations)/n_blocks);
    s = 1:step:length(all_combinations);
    blocks = cell(length(s),1);
    for b = 1:length(s)
        blocks{b} = all_combinations(s(b):min(s(b)+step-1,length(all_combinations)),:);
    end

    combs = blocks{blocknr};
    save(outfn_pairs, 'combs')
    nproc = cosmo_parallel_get_nproc_available;

    res = [];
    for pairs = 1:length(combs)
        tic
        disp([num2str(pairs) ' out of ' num2str(length(combs))])
        ds_p = cosmo_slice(ds,ismember(ds.sa.things_category_nr,combs(pairs,:)));
        partitions = cosmo_nfold_partitioner(ds_p); 
        measure_args=struct(); 
        measure_args.classifier=@cosmo_classify_lda;
        measure_args.partitions=partitions;
        measure_args.nproc = nproc;
        nbrhood=cosmo_interval_neighborhood(ds_p,'time','radius',0);
        res{pairs}=cosmo_searchlight(ds_p,nbrhood,@cosmo_crossvalidation_measure,measure_args);
        toc
    end
    res_pairs = cosmo_stack(res);
    save(outfn, 'res_pairs','-v7.3')
 
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