Home > NoiseTools > nt_fold.m

# nt_fold

## PURPOSE

y=fold(x,epochsize) - fold 2D to 3D

## SYNOPSIS

function x=fold(x,epochsize)

## DESCRIPTION

    y=fold(x,epochsize) - fold 2D to 3D

      y: 3D matrix of (time * channel * trial)

      x: 2D matrix of concatentated data (time * channel)
      epochsize: number of samples in each trial

     NoiseTools

## CROSS-REFERENCE INFORMATION

This function calls:

- nt_greetings nt_greetings - display message the first time the toolbox is used

This function is called by:

- nt_demean [y,mn]=nt_demean(x,w) - remove weighted mean over cols
- nt_fixsign y=nt_fixsign(x) - flip signs to maximize inter-component correlation
- nt_growmask ww=nt_growmask(w,margin) - widen mask
- nt_mmat y=nt_mmat(x,m) - matrix multiplication (with convolution)
- nt_normcol [y,norm]=nt_normcol(x,w) - normalize each column so its weighted msq is 1
- nt_regw [b,z]=nt_regw(y,x,w) - weighted regression
- nt_sns y=nt_sns(x,nneigbors,skip,w) - sensor noise suppression
- nt_sns_cluster y=nt_sns_cluster(x,nneigbors,cluster_size) - sensor noise suppression within clusters
- nt_star [y,w,ww]=nt_star(x,thresh,closest,depth) - sensor noise suppression
- nt_star2 [y,w,ww]=nt_star2(x,thresh,closest,w) - sensor noise suppression
- nt_tsregress [z,idx]=nt_tsregress(x,y,shifts,xw,yw,keep,threshold) - time-shift regression
- nt_tsxcov [c,tw]=nt_tsxcov(x,y,shifts,w) - cross-covariance of X and time-shifted Y
- nt_vecadd y=nt_vecadd(x,v) - add vector to all rows or columns of matrix
- nt_vecmult y=nt_vecmult(x,v) - multiply all rows or columns of matrix by vector
- nt_xcov [c,tw]=nt_xcov(x,y,shifts,w) - cross-covariance of X and time-shifted Y
- nt_xprod [y,ind]=nt_xprod(x,flag,dsratio,normrow_flag) - form all crossproducts
- nt_xprod2 [y,ind]=nt_xprod(x1,x2,dsratio) - form all crossproducts

## SOURCE CODE

    0001 function x=fold(x,epochsize)
    0002 %y=fold(x,epochsize) - fold 2D to 3D
    0003 %
    0004 %  y: 3D matrix of (time * channel * trial)
    0005 %
    0006 %  x: 2D matrix of concatentated data (time * channel)
    0007 %  epochsize: number of samples in each trial
    0008 %
    0009 % NoiseTools
    0010
    0011 nt_greetings;
    0012
    0013 if isempty(x);
    0014     x=[];
    0015 else
    0016     if size(x,1)/epochsize>1
    0017         x=permute(reshape(x,[epochsize, size(x,1)/epochsize, size(x,2)]), [1 3 2]);
    0018     else
    0019         x=x;
    0020     end
    0021 end