The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

2026-09-13 @Atsushi Kawaguchi

The mand package provides functions for multivariate analysis for neuroimaging data.

library(mand)
library(msma)
## Warning: package 'msma' was built under R version 4.5.3

Introduction

Template

One subject image as the template is available in the mand package. The coad to load it is as follows.

data(template)

The image is compressed because of storage and computation time. The dimension is confirmed as follows.

dim(template)
## Loading required namespace: oro.nifti
## [1] 30 36 30

The image is plotted by the coat function.

coat(template)

Other options with the plane argument (such as “axial,” “coronal,” “sagittal,” and “all”) are available. The default setting is “axial”. If the argument is specified as plane="all", three directional slices at a certain coordinate are plotted.

coat(x=template, plane="all")

Image Data Matrix

The imgdatamat function reads image files saved in the nifti format and creates data matrix with subjects in row and voxel in column (this example does not work).

fnames1 = c("data1.nii", "data2.nii")
imgmat = imgdatamat(fnames1, simscale=1/4)

The first argument is file names with the length equaling the number of subjects (the number of rows in the resulting data matrix). The second argument simscale is the image resize scale. In this example, the all sizes (number of voxel) for three direction was reduced into its quarter size. The output is the list form where the “S” is data matrix, the “brainpos” is a binary image indicating brain region, and the “imagedim” is image dimension. The ROI (Region Of Interest) volume is computed in the “roi” if the ROI argument is TRUE.

imgmat = imgdatamat(fnames1, schange=TRUE, simscale=1/4, ROI=TRUE)

Overlay

The resulting map from the statistical analysis such as the t statistics map from the SPM is represented with overlapping on the template. For example, the mand package has the average difference assuming Alzheimer’s disease and healthy subjects with the array format.

The overlay is implemented by the coat function.

data(diffimg)
coat(template, diffimg)

Atlas

Anatomical brain segmentation region is useful for the plot and the interpretation. For example, the Automated Anatomical Labeling (AAL) atlas is used. The data.frame has two columns (“ROIid” and “ROIname”) format.

data(atlasdatasets)
atlasname = "aal3"
atlasdataset = atlasdatasets[[atlasname]]
head(atlasdataset)
##   ROIid                                   ROIname
## 1     1                     Left Precentral gyrus
## 2     2                    Right Precentral gyrus
## 3     3  Left Superior frontal gyrus-dorsolateral
## 4     4 Right Superior frontal gyrus-dorsolateral
## 5     5                 Left Middle frontal gyrus
## 6     6                Right Middle frontal gyrus

It is also neccesary to prepare the array data.

data(atlas)
tmpatlas = atlas[[atlasname]]
dim(tmpatlas)
## [1] 30 36 30

It has the ROIid as the element.

tmpatlas[,15:20,12]
##       [,1] [,2] [,3] [,4] [,5] [,6]
##  [1,]    0    0    0    0    0    0
##  [2,]    0    0    0    0    0    0
##  [3,]   90   90   90   90   90   90
##  [4,]   94   94   90   90   90   90
##  [5,]   94   94   90   90   90   90
##  [6,]   94   90   90   90   90   90
##  [7,]   94    0    0    0   90   90
##  [8,]    0    0    0    0    0    0
##  [9,]   60   44   42   42   42    0
## [10,]   60   44   42   42   42   42
## [11,]   44   44   42   42   42   42
## [12,]   44   44   44    0    0   42
## [13,]   52    0    0    0    0    0
## [14,]  100    0    0  162  162  164
## [15,]  114    0    0  166  166    0
## [16,]    0    0    0    0    0    0
## [17,]   99    0    0  165    0    0
## [18,]  101  101    0  163  163  163
## [19,]   43    0    0    0    0   41
## [20,]    0   43   41   41   41   41
## [21,]   43   43   41   41   41   41
## [22,]   43   43   41   41   41   41
## [23,]    0    0    0    0    0    0
## [24,]   93    0    0    0    0    0
## [25,]   93    0    0   89   89   89
## [26,]   93   89   89   89   89   89
## [27,]   89   89   89   89   89   89
## [28,]   89   89   89   89   89   89
## [29,]    0   89   89   89   89    0
## [30,]    0    0    0    0    0    0

The anatomical region can be plotted by the coat function with regionplot=TRUE.

coat(template, tmpatlas, regionplot=TRUE, 
atlasdataset=atlasdataset, ROIids = c(1:2, 41:44), regionlegend=TRUE)

The resulting map can be converted into the summary of the anatomical regions.

atlastable(tmpatlas, diffimg, atlasdataset, ROIids = c(1:2, 41:44))
## $table
##    ROIid                     ROIname sizenum   sizepct    sumvalue       Min. 1st Qu. Median          Mean 3rd Qu.      Max.
## 1      1       Left Precentral gyrus     116 0.6170213   8.2999981 -0.5675001       0      0  2.561728e-04       0 0.8024999
## 2      2      Right Precentral gyrus     115 0.6318681  -0.3050001 -0.7349999       0      0 -9.413584e-06       0 0.7499998
## 41    41            Left Hippocampus      26 0.5909091  -7.1899993 -1.0000000       0      0 -2.219136e-04       0 0.4475000
## 42    42           Right Hippocampus      33 0.7333333 -12.1099996 -0.9675000       0      0 -3.737654e-04       0 0.5049999
## 43    43  Left Parahippocampal gyrus      30 0.7317073  -5.4949995 -0.8750000       0      0 -1.695988e-04       0 0.5300001
## 44    44 Right Parahippocampal gyrus      27 0.6923077  -3.1474993 -0.7500000       0      0 -9.714504e-05       0 0.6899998
## 
## attr(,"class")
## [1] "atlastable"

The outputs are the number of voxel in the sizenum column, the percentage of the voxel in the sizepct column, and the minimum, mean, and maximum valued of the region of the overlaying map. The order of the table row is in the larger absolute value of the minimum or maximum values.

The brain image corresponding to the region of interest can be extracted as follows. First, we create a mask image in which the hippocampal region is represented by 1 and others by 0. Then the product of the template and the mask image is taken for each voxel.

hipmask = (tmpatlas == 41) + (tmpatlas == 42)
template2 = template * hipmask

The images generated by these processes are plotted from left to right in one slice.

par(mfrow=c(1,3), mar=rep(1,4))
coat(template, pseq=12, paron=FALSE)
coat(hipmask, pseq=12, paron=FALSE)
coat(template2, pseq=12, paron=FALSE)

The template image (left) and the mask image (middle) are multiplied voxel by voxel to obtain the only hippocampus region image (right).

The sum of the voxel values in the region is calculated as follows.

sum(template[which(hipmask==1, arr.ind = TRUE)])/1000
## [1] 0.07090703

Such a value is calculated for each region and a dataset with ROI values is created.

Principal Component Analysis

Generate Simulation Data

The mand package has a function to generate simulation brain data from the base image, the difference image and the standard deviation image. These basic images are loaded as follows.

data(baseimg)
data(diffimg)
data(mask)
data(sdevimg)

The number of voxels in the original 3D image is as follows.

dim(baseimg)
## [1] 30 36 30

To understand the result easily, the difference region was restricted to Parahippocampus and Hippocampus.

diffimg2 = diffimg * (tmpatlas %in% 41:44)

An image data matrix with subjects in the rows and voxels in the columns was generated by using the simbrain function.

img1 = simbrain(baseimg = baseimg, diffimg = diffimg2, 
sdevimg=sdevimg, mask=mask, n0=20, c1=0.01, sd1=0.05)

The base image, the difference image and the standard deviation image were specified in the first three arguments. The out-of-brain region was specified by the mask argument, which was the binary image. The remaining arguments are the number of subjects per group, the coefficient multiplied by the difference image and the standard deviation for the noise.

The data matrix dimension was 40(subject) x 12620(voxel).

dim(img1$S)
## [1]    40 12620

The rec function creates the 3D image from the vectorized data (the first subject).

coat(rec(img1$S[1,], img1$imagedim, mask=img1$brainpos))

The standard deviation image is created from the resulting data matrix.

sdimg = apply(img1$S, 2, sd)
coat(template, rec(sdimg, img1$imagedim, mask=img1$brainpos))

Principal Component Analysis

If the input is a matrix, a principal component analysis is implemented by the msma function of the msma package. Principal component analysis with the number of components of 2 for the image data matrix is performed as follows.

(fit111 = msma(img1$S, comp=2))
## Call:
## .msma_default_legacy(X = X, Y = Y, Z = Z_legacy, comp = comp, 
##     lambdaX = lambdaX, lambdaY = lambdaY, lambdaXsup = lambdaXsup, 
##     lambdaYsup = lambdaYsup, eta = eta, type = type, inX = inX, 
##     inY = inY, inXsup = inXsup, inYsup = inYsup, muX = muX, muY = muY, 
##     defmethod = defmethod, scaling = scaling, verbose = verbose, 
##     intseed = intseed, ceps = ceps)
## 
## Numbers of non-zeros for X block: 
##        comp1 comp2
## block1  9865  9865
## 
## Numbers of non-zeros for X super: 
##         comp1 comp2
## comp1-1     1     1

The scatter plots for the score vectors specified by the argument v. The argument axes is specified by the two length vectors on which components are displayed.

plot(fit111, v="score", axes = 1:2, plottype="scatter")

The weight (loading) vectors can be obtained and reconstructed as follows.

midx = 1 ## the index for the modality
vidx = 1 ## the index for the component
Q = fit111$wbX[[midx]][,vidx]
outstat1 = rec(Q, img1$imagedim, mask=img1$brainpos)

The reconstructed loadings as image is overlayed on the template.

coat(template, outstat1)

The output is unclear; however, this will be improved later.

Two-steps dimension reduction

Basis Expansion

This is an example of the two-step dimension reduction.

Generate radial basis function.

B1 = rbfunc(imagedim=img1$imagedim, seppix=2, hispec=FALSE, mask=img1$brainpos)

Multiplying the basis function to image data matrix.

SB1 = basisprod(img1$S, B1)

The original dimension was 12620.

dim(img1$S)
## [1]    40 12620

The dimension was reduced to 1604.

dim(SB1)
## [1]   40 1604

Principal Component Analysis

The Principal Component Analysis (PCA) is applied to the dimension-reduced image.

(fit211 = msma(SB1, comp=2))
## Call:
## .msma_default_legacy(X = X, Y = Y, Z = Z_legacy, comp = comp, 
##     lambdaX = lambdaX, lambdaY = lambdaY, lambdaXsup = lambdaXsup, 
##     lambdaYsup = lambdaYsup, eta = eta, type = type, inX = inX, 
##     inY = inY, inXsup = inXsup, inYsup = inYsup, muX = muX, muY = muY, 
##     defmethod = defmethod, scaling = scaling, verbose = verbose, 
##     intseed = intseed, ceps = ceps)
## 
## Numbers of non-zeros for X block: 
##        comp1 comp2
## block1  1604  1604
## 
## Numbers of non-zeros for X super: 
##         comp1 comp2
## comp1-1     1     1

The loading is reconstructed to the original space by using the rec function.

Q = fit211$wbX[[1]][,1]
outstat1 = rec(Q, img1$imagedim, B=B1, mask=img1$brainpos)

The plotted loading is smoother than the one without the dimension reduction by the basis function.

coat(template, outstat1)

Sparse PCA

If lambdaX (>0) is specified, a sparse principal component analysis is implemented.

(fit112 = msma(SB1, comp=2, lambdaX=0.06))
## Call:
## .msma_default_legacy(X = X, Y = Y, Z = Z_legacy, comp = comp, 
##     lambdaX = lambdaX, lambdaY = lambdaY, lambdaXsup = lambdaXsup, 
##     lambdaYsup = lambdaYsup, eta = eta, type = type, inX = inX, 
##     inY = inY, inXsup = inXsup, inYsup = inYsup, muX = muX, muY = muY, 
##     defmethod = defmethod, scaling = scaling, verbose = verbose, 
##     intseed = intseed, ceps = ceps)
## 
## Numbers of non-zeros for X block: 
##        comp1 comp2
## block1    53    40
## 
## Numbers of non-zeros for X super: 
##         comp1 comp2
## comp1-1     1     1

The plotted loading is narrower than that from the PCA.

Q = fit112$wbX[[midx]][,vidx]
outstat1 = rec(Q, img1$imagedim, B=B1, mask=img1$brainpos)
outstat2 = outstat1
coat(template, outstat2)

The region is reported as follows to be compared with the next method.

atlastable(tmpatlas, outstat2, atlasdataset)
## $table
##     ROIid                                                                ROIname sizenum    sizepct     sumvalue Min. 1st Qu. Median         Mean 3rd Qu.         Max.
## 1       1                                                  Left Precentral gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 2       2                                                 Right Precentral gyrus      56 0.30769231 4.748789e-01    0       0      0 1.465676e-05       0 1.424819e-01
## 3       3                               Left Superior frontal gyrus-dorsolateral     180 0.72000000 8.552688e+01    0       0      0 2.639719e-03       0 2.332348e+00
## 4       4                              Right Superior frontal gyrus-dorsolateral     207 0.84489796 2.577099e+02    0       0      0 7.954008e-03       0 5.165228e+00
## 5       5                                              Left Middle frontal gyrus     152 0.60317460 7.292652e+00    0       0      0 2.250818e-04       0 5.065971e-01
## 6       6                                             Right Middle frontal gyrus     243 0.97590361 1.277586e+02    0       0      0 3.943165e-03       0 3.423288e+00
## 7       7                             Left Inferior frontal gyrus-opercular part       7 0.11475410 2.861414e-03    0       0      0 8.831525e-08       0 1.440939e-03
## 8       8                            Right Inferior frontal gyrus-opercular part      64 0.94117647 5.151732e+00    0       0      0 1.590041e-04       0 5.929501e-01
## 9       9                            Left Inferior frontal gyrus-triangular part      57 0.50892857 6.078731e-01    0       0      0 1.876151e-05       0 1.129497e-01
## 10     10                           Right Inferior frontal gyrus-triangular part     115 0.99137931 2.188454e+01    0       0      0 6.754489e-04       0 1.911110e+00
## 11     11                                                Left IFG pars orbitalis      21 0.58333333 4.266604e-01    0       0      0 1.316853e-05       0 1.065023e-01
## 12     12                                               Right IFG pars orbitalis      43 0.93478261 2.176215e+00    0       0      0 6.716713e-05       0 5.083335e-01
## 13     13                                                Left Rolandic operculum       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 14     14                                               Right Rolandic operculum      12 0.16438356 1.019422e-02    0       0      0 3.146363e-07       0 6.472303e-03
## 15     15                                          Left Supplementary motor area      35 0.40229885 7.773107e-01    0       0      0 2.399107e-05       0 2.312197e-01
## 16     16                                         Right Supplementary motor area      58 0.54716981 3.673874e+00    0       0      0 1.133912e-04       0 7.358109e-01
## 17     17                                                  Left Olfactory cortex      11 0.91666667 4.855253e+00    0       0      0 1.498535e-04       0 1.829529e+00
## 18     18                                                 Right Olfactory cortex      11 1.00000000 6.328657e+00    0       0      0 1.953289e-04       0 2.354883e+00
## 19     19                                     Left Superior frontal gyrus-medial     115 1.00000000 2.375736e+02    0       0      0 7.332519e-03       0 6.165573e+00
## 20     20                                    Right Superior frontal gyrus-medial      94 1.00000000 2.264148e+02    0       0      0 6.988112e-03       0 6.113931e+00
## 21     21                             Left Superior frontal gyrus-medial orbital      32 1.00000000 2.120301e+01    0       0      0 6.544138e-04       0 1.629459e+00
## 22     22                            Right Superior frontal gyrus-medial orbital      39 1.00000000 2.970613e+01    0       0      0 9.168558e-04       0 2.010142e+00
## 23     23                                                      Left Gyrus rectus      27 1.00000000 3.744205e+00    0       0      0 1.155619e-04       0 3.113401e-01
## 24     24                                                     Right Gyrus rectus      21 1.00000000 4.476652e+00    0       0      0 1.381683e-04       0 4.301427e-01
## 25     25                                              Left Medial orbital gyrus      17 1.00000000 1.269704e+00    0       0      0 3.918840e-05       0 1.704211e-01
## 26     26                                             Right Medial orbital gyrus      15 1.00000000 2.378205e+00    0       0      0 7.340137e-05       0 2.864638e-01
## 27     27                                            Left Anterior orbital gyrus       9 1.00000000 3.576257e-01    0       0      0 1.103783e-05       0 1.330053e-01
## 28     28                                           Right Anterior orbital gyrus      21 1.00000000 3.157526e+00    0       0      0 9.745450e-05       0 4.529979e-01
## 29     29                                           Left Posterior orbital gyrus      11 0.64705882 5.391140e-02    0       0      0 1.663932e-06       0 1.964482e-02
## 30     30                                          Right Posterior orbital gyrus      17 1.00000000 1.334172e+00    0       0      0 4.117815e-05       0 2.486018e-01
## 31     31                                             Left Lateral orbital gyrus       2 1.00000000 2.524063e-04    0       0      0 7.790319e-09       0 1.463614e-04
## 32     32                                            Right Lateral orbital gyrus       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 33     33                                                            Left Insula      38 0.39583333 1.511061e+00    0       0      0 4.663770e-05       0 3.174231e-01
## 34     34                                                           Right Insula      63 0.64948454 7.451335e+00    0       0      0 2.299795e-04       0 1.041648e+00
## 35     35                           Left Anterior cingulate & paracingulate gyri       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 36     36                          Right Anterior cingulate & paracingulate gyri       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 37     37                             Left Middle cingulate & paracingulate gyri      29 0.30851064 6.714268e+00    0       0      0 2.072305e-04       0 1.478810e+00
## 38     38                            Right Middle cingulate & paracingulate gyri      45 0.45918367 4.031853e+01    0       0      0 1.244399e-03       0 5.686351e+00
## 39     39                                         Left Posterior cingulate gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 40     40                                        Right Posterior cingulate gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 41     41                                                       Left Hippocampus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 42     42                                                      Right Hippocampus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 43     43                                             Left Parahippocampal gyrus       1 0.02439024 8.086059e-06    0       0      0 2.495697e-10       0 8.086059e-06
## 44     44                                            Right Parahippocampal gyrus       1 0.02564103 1.728440e-04    0       0      0 5.334690e-09       0 1.728440e-04
## 45     45                                                          Left Amygdala       1 0.09090909 3.870510e-05    0       0      0 1.194602e-09       0 3.870510e-05
## 46     46                                                         Right Amygdala       7 0.53846154 7.060743e-03    0       0      0 2.179242e-07       0 3.596136e-03
## 47     47                          Left Calcarine fissure and surrounding cortex       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 48     48                         Right Calcarine fissure and surrounding cortex       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 49     49                                                            Left Cuneus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 50     50                                                           Right Cuneus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 51     51                                                     Left Lingual gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 52     52                                                    Right Lingual gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 53     53                                          Left Superior occipital gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 54     54                                         Right Superior occipital gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 55     55                                            Left Middle occipital gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 56     56                                           Right Middle occipital gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 57     57                                          Left Inferior occipital gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 58     58                                         Right Inferior occipital gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 59     59                                                    Left Fusiform gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 60     60                                                   Right Fusiform gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 61     61                                                 Left Postcentral gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 62     62                                                Right Postcentral gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 63     63                                           Left Superior parietal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 64     64                                          Right Superior parietal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 65     65  Left Inferior parietal gyrus-excluding supramarginal and angular gyri       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 66     66 Right Inferior parietal gyrus-excluding supramarginal and angular gyri       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 67     67                                               Left SupraMarginal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 68     68                                              Right SupraMarginal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 69     69                                                     Left Angular gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 70     70                                                    Right Angular gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 71     71                                                         Left Precuneus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 72     72                                                        Right Precuneus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 73     73                                                Left Paracentral lobule       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 74     74                                               Right Paracentral lobule       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 75     75                                                   Left Caudate nucleus      35 0.94594595 1.575101e+01    0       0      0 4.861422e-04       0 1.417868e+00
## 76     76                                                  Right Caudate nucleus      48 0.96000000 4.136425e+01    0       0      0 1.276674e-03       0 2.408496e+00
## 77     77                                        Left Lenticular nucleus-Putamen      37 0.68518519 1.955917e+00    0       0      0 6.036782e-05       0 3.002033e-01
## 78     78                                       Right Lenticular nucleus-Putamen      50 0.86206897 6.975001e+00    0       0      0 2.152778e-04       0 7.603229e-01
## 79     79                                       Left Lenticular nucleus-Pallidum      11 1.00000000 1.607813e-01    0       0      0 4.962386e-06       0 5.541498e-02
## 80     80                                      Right Lenticular nucleus-Pallidum      10 0.90909091 6.973981e-01    0       0      0 2.152463e-05       0 2.784539e-01
## 81     81                                                          Left Thalamus       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 82     82                                                         Right Thalamus       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 83     83                                                     Left Heschls gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 84     84                                                    Right Heschls gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 85     85                                           Left Superior temporal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 86     86                                          Right Superior temporal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 87     87                            Left Temporal pole: superior temporal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 88     88                           Right Temporal pole: superior temporal gyrus      15 0.22058824 2.735908e-03    0       0      0 8.444162e-08       0 1.032239e-03
## 89     89                                             Left Middle temporal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 90     90                                            Right Middle temporal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 91     91                              Left Temporal pole: middle temporal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 92     92                             Right Temporal pole: middle temporal gyrus       1 0.01886792 4.699404e-06    0       0      0 1.450433e-10       0 4.699404e-06
## 93     93                                           Left Inferior temporal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 94     94                                          Right Inferior temporal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 95     95                                   Left Crus I of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 96     96                                  Right Crus I of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 97     97                                  Left Crus II of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 98     98                                 Right Crus II of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 99     99                               Left Lobule III of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 100   100                              Right Lobule III of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 101   101                              Left Lobule IV-V of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 102   102                             Right Lobule IV-V of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 103   103                                Left Lobule VI of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 104   104                               Right Lobule VI of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 105   105                              Left Lobule VIIB of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 106   106                             Right Lobule VIIB of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 107   107                              Left Lobule VIII of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 108   108                             Right Lobule VIII of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 109   109                                Left Lobule IX of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 110   110                               Right Lobule IX of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 111   111                                 Left Lobule X of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 112   112                                Right Lobule X of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 113   113                                                  Lobule I-II of vermis       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 114   114                                                   Lobule III of vermis       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 115   115                                                  Lobule IV-V of vermis       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 116   116                                                    Lobule VI of vermis       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 117   117                                                   Lobule VII of vermis       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 118   118                                                  Lobule VIII of vermis       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 119   119                                                    Lobule IX of vermis       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 120   120                                                     Lobule X of vermis       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 121   121                                    Left Thalamus-Anteroventral Nucleus       1 1.00000000 3.233869e-03    0       0      0 9.981077e-08       0 3.233869e-03
## 122   122                                   Right Thalamus-Anteroventral Nucleus       2 1.00000000 6.359419e-02    0       0      0 1.962784e-06       0 5.889710e-02
## 123   123                                                 Left Lateral posterior       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 124   124                                                Right Lateral posterior       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 125   125                                                  Left Ventral anterior       3 1.00000000 4.623904e-02    0       0      0 1.427131e-06       0 2.640670e-02
## 126   126                                                 Right Ventral anterior       5 1.00000000 1.761699e-01    0       0      0 5.437343e-06       0 4.988060e-02
## 127   127                                                   Left Ventral lateral       4 0.26666667 4.858415e-03    0       0      0 1.499511e-07       0 1.955612e-03
## 128   128                                                  Right Ventral lateral       6 0.54545455 1.652199e-02    0       0      0 5.099380e-07       0 3.867090e-03
## 129   129                                            Left Ventral posterolateral       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 130   130                                           Right Ventral posterolateral       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 131   131                                                      Left Intralaminar       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 132   132                                                     Right Intralaminar       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 133   133                                                          Left Reuniens       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 134   134                                                         Right Reuniens       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 135   135                                  Left Mediodorsal medial magnocellular       1 0.11111111 1.916387e-03    0       0      0 5.914774e-08       0 1.916387e-03
## 136   136                                 Right Mediodorsal medial magnocellular       1 0.11111111 3.580514e-03    0       0      0 1.105097e-07       0 3.580514e-03
## 137   137                                 Left Mediodorsal lateral parvocellular       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 138   138                                Right Mediodorsal lateral parvocellular       1 0.25000000 4.886574e-03    0       0      0 1.508202e-07       0 4.886574e-03
## 139   139                                                Left Lateral geniculate       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 140   140                                               Right Lateral geniculate       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 141   141                                                 Left Medial Geniculate       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 142   142                                                Right Medial Geniculate       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 143   143                                                 Left Pulvinar anterior       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 144   144                                                Right Pulvinar anterior       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 145   145                                                   Left Pulvinar medial       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 146   146                                                  Right Pulvinar medial       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 147   147                                                  Left Pulvinar lateral       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 148   148                                                 Right Pulvinar lateral       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 149   149                                                 Left Pulvinar inferior       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 150   150                                                Right Pulvinar inferior       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 151   151                               Left Anterior cingulate cortex-subgenual      10 1.00000000 1.522313e+01    0       0      0 4.698496e-04       0 2.916240e+00
## 152   152                              Right Anterior cingulate cortex-subgenual       6 1.00000000 1.353748e+01    0       0      0 4.178233e-04       0 3.413513e+00
## 153   153                               Left Anterior cingulate cortex-pregenual      35 1.00000000 1.331032e+02    0       0      0 4.108123e-03       0 6.943993e+00
## 154   154                              Right Anterior cingulate cortex-pregenual      36 1.00000000 2.089043e+02    0       0      0 6.447665e-03       0 7.480375e+00
## 155   155                           Left Anterior cingulate cortex-supracallosal      39 1.00000000 1.069481e+02    0       0      0 3.300868e-03       0 6.448857e+00
## 156   156                          Right Anterior cingulate cortex-supracallosal      31 1.00000000 1.361975e+02    0       0      0 4.203627e-03       0 6.880439e+00
## 157   157                                                 Left Nucleus accumbens       7 1.00000000 1.878194e+00    0       0      0 5.796894e-05       0 6.456946e-01
## 158   158                                                Right Nucleus accumbens       7 1.00000000 3.141609e+00    0       0      0 9.696323e-05       0 8.745726e-01
## 159   159                                            Left Ventral tegmental area       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 160   160                                           Right Ventral tegmental area       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 161   161                                    Left Substantia nigra-pars compacta       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 162   162                                   Right Substantia nigra-pars compacta       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 163   163                                  Left Substantia nigra-pars reticulata       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 164   164                                 Right Substantia nigra-pars reticulata       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 165   165                                                       Left Red nucleus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 166   166                                                      Right Red nucleus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 167   167                                                   Left Locus coeruleus       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 168   168                                                  Right Locus coeruleus       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 169   169                                                   Raphe nucleus-dorsal       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 170   170                                                   Raphe nucleus-median       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 
## attr(,"class")
## [1] "atlastable"

Supervised Sparse PCA

The simbrain generates the synthetic brain image data and the binary outcome. The outcome Z is obtained.

Z = img1$Z

If the outcome Z is specified in the msma function, a supervised sparse principal component analysis is implemented.

(fit113 = msma(SB1, Z=Z, comp=2, lambdaX=0.06, muX=0.5))
## Call:
## .msma_default_legacy(X = X, Y = Y, Z = Z_legacy, comp = comp, 
##     lambdaX = lambdaX, lambdaY = lambdaY, lambdaXsup = lambdaXsup, 
##     lambdaYsup = lambdaYsup, eta = eta, type = type, inX = inX, 
##     inY = inY, inXsup = inXsup, inYsup = inYsup, muX = muX, muY = muY, 
##     defmethod = defmethod, scaling = scaling, verbose = verbose, 
##     intseed = intseed, ceps = ceps)
## 
## Numbers of non-zeros for X block: 
##        comp1 comp2
## block1    48    38
## 
## Numbers of non-zeros for X super: 
##         comp1 comp2
## comp1-1     1     1

The plotted loading is located differently from the sparse PCA.

Q = fit113$wbX[[1]][,1]
outstat1 = rec(Q, img1$imagedim, B=B1, mask=img1$brainpos)
outstat2 = -outstat1
coat(template, outstat2)

The region near the hippocampus, which differs from the sparse PCA (without supervision).

atlastable(tmpatlas, outstat2, atlasdataset)
## $table
##     ROIid                                                                ROIname sizenum    sizepct     sumvalue Min. 1st Qu. Median         Mean 3rd Qu.         Max.
## 1       1                                                  Left Precentral gyrus     124 0.65957447 1.062377e+01    0       0      0 3.278941e-04       0 8.569300e-01
## 2       2                                                 Right Precentral gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 3       3                               Left Superior frontal gyrus-dorsolateral       1 0.00400000 3.337561e-05    0       0      0 1.030111e-09       0 3.337561e-05
## 4       4                              Right Superior frontal gyrus-dorsolateral       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 5       5                                              Left Middle frontal gyrus      17 0.06746032 3.876795e-02    0       0      0 1.196542e-06       0 1.360439e-02
## 6       6                                             Right Middle frontal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 7       7                             Left Inferior frontal gyrus-opercular part      59 0.96721311 2.314522e+00    0       0      0 7.143586e-05       0 2.362614e-01
## 8       8                            Right Inferior frontal gyrus-opercular part       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 9       9                            Left Inferior frontal gyrus-triangular part       9 0.08035714 6.248256e-02    0       0      0 1.928474e-06       0 2.964117e-02
## 10     10                           Right Inferior frontal gyrus-triangular part       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 11     11                                                Left IFG pars orbitalis       7 0.19444444 1.908029e-03    0       0      0 5.888979e-08       0 6.357083e-04
## 12     12                                               Right IFG pars orbitalis       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 13     13                                                Left Rolandic operculum      56 1.00000000 1.254762e+02    0       0      0 3.872724e-03       0 5.222454e+00
## 14     14                                               Right Rolandic operculum       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 15     15                                          Left Supplementary motor area       1 0.01149425 6.998475e-06    0       0      0 2.160023e-10       0 6.998475e-06
## 16     16                                         Right Supplementary motor area       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 17     17                                                  Left Olfactory cortex      10 0.83333333 3.775781e-01    0       0      0 1.165364e-05       0 1.950686e-01
## 18     18                                                 Right Olfactory cortex       2 0.18181818 1.446679e-05    0       0      0 4.465060e-10       0 1.120140e-05
## 19     19                                     Left Superior frontal gyrus-medial       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 20     20                                    Right Superior frontal gyrus-medial       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 21     21                             Left Superior frontal gyrus-medial orbital       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 22     22                            Right Superior frontal gyrus-medial orbital       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 23     23                                                      Left Gyrus rectus       6 0.22222222 2.310631e-02    0       0      0 7.131576e-07       0 1.401455e-02
## 24     24                                                     Right Gyrus rectus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 25     25                                              Left Medial orbital gyrus       4 0.23529412 2.750149e-02    0       0      0 8.488115e-07       0 1.585314e-02
## 26     26                                             Right Medial orbital gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 27     27                                            Left Anterior orbital gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 28     28                                           Right Anterior orbital gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 29     29                                           Left Posterior orbital gyrus      12 0.70588235 2.083022e-01    0       0      0 6.429081e-06       0 6.971438e-02
## 30     30                                          Right Posterior orbital gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 31     31                                             Left Lateral orbital gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 32     32                                            Right Lateral orbital gyrus       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 33     33                                                            Left Insula      88 0.91666667 1.009409e+02    0       0      0 3.115460e-03       0 5.909930e+00
## 34     34                                                           Right Insula       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 35     35                           Left Anterior cingulate & paracingulate gyri       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 36     36                          Right Anterior cingulate & paracingulate gyri       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 37     37                             Left Middle cingulate & paracingulate gyri      63 0.67021277 2.582099e+00    0       0      0 7.969440e-05       0 3.027063e-01
## 38     38                            Right Middle cingulate & paracingulate gyri      32 0.32653061 1.769562e-01    0       0      0 5.461610e-06       0 2.593513e-02
## 39     39                                         Left Posterior cingulate gyrus      17 1.00000000 6.040326e+00    0       0      0 1.864298e-04       0 1.881986e+00
## 40     40                                        Right Posterior cingulate gyrus      11 1.00000000 4.148732e-01    0       0      0 1.280473e-05       0 1.291099e-01
## 41     41                                                       Left Hippocampus      44 1.00000000 1.290294e+02    0       0      0 3.982388e-03       0 6.665653e+00
## 42     42                                                      Right Hippocampus       1 0.02222222 5.363438e-03    0       0      0 1.655382e-07       0 5.363438e-03
## 43     43                                             Left Parahippocampal gyrus      41 1.00000000 7.173206e+01    0       0      0 2.213952e-03       0 5.094835e+00
## 44     44                                            Right Parahippocampal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 45     45                                                          Left Amygdala      11 1.00000000 5.659849e+00    0       0      0 1.746867e-04       0 9.840613e-01
## 46     46                                                         Right Amygdala       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 47     47                          Left Calcarine fissure and surrounding cortex      52 0.58426966 1.290853e+01    0       0      0 3.984116e-04       0 1.525031e+00
## 48     48                         Right Calcarine fissure and surrounding cortex      12 0.12371134 1.814160e-02    0       0      0 5.599260e-07       0 7.291375e-03
## 49     49                                                            Left Cuneus      28 0.42424242 1.251272e+00    0       0      0 3.861951e-05       0 3.980086e-01
## 50     50                                                           Right Cuneus       3 0.03750000 3.970363e-03    0       0      0 1.225421e-07       0 3.636119e-03
## 51     51                                                     Left Lingual gyrus      81 0.85263158 6.654842e+01    0       0      0 2.053964e-03       0 4.584649e+00
## 52     52                                                    Right Lingual gyrus      36 0.36734694 9.150443e-02    0       0      0 2.824211e-06       0 2.880567e-02
## 53     53                                          Left Superior occipital gyrus      36 0.52941176 3.233000e-01    0       0      0 9.978396e-06       0 9.194631e-02
## 54     54                                         Right Superior occipital gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 55     55                                            Left Middle occipital gyrus     146 0.90123457 4.034731e+00    0       0      0 1.245287e-04       0 6.797666e-01
## 56     56                                           Right Middle occipital gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 57     57                                          Left Inferior occipital gyrus      36 0.76595745 1.245488e+00    0       0      0 3.844098e-05       0 4.904622e-01
## 58     58                                         Right Inferior occipital gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 59     59                                                    Left Fusiform gyrus     102 0.99029126 7.356566e+01    0       0      0 2.270545e-03       0 2.946326e+00
## 60     60                                                   Right Fusiform gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 61     61                                                 Left Postcentral gyrus     133 0.70370370 5.293517e+01    0       0      0 1.633801e-03       0 2.473056e+00
## 62     62                                                Right Postcentral gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 63     63                                           Left Superior parietal gyrus      23 0.18852459 3.733082e-02    0       0      0 1.152186e-06       0 1.124865e-02
## 64     64                                          Right Superior parietal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 65     65  Left Inferior parietal gyrus-excluding supramarginal and angular gyri     121 0.98373984 2.318386e+01    0       0      0 7.155511e-04       0 1.431804e+00
## 66     66 Right Inferior parietal gyrus-excluding supramarginal and angular gyri       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 67     67                                               Left SupraMarginal gyrus      61 1.00000000 5.920034e+01    0       0      0 1.827171e-03       0 3.497201e+00
## 68     68                                              Right SupraMarginal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 69     69                                                     Left Angular gyrus      67 1.00000000 9.352486e+00    0       0      0 2.886570e-04       0 8.777804e-01
## 70     70                                                    Right Angular gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 71     71                                                         Left Precuneus      56 0.42424242 1.657144e+01    0       0      0 5.114642e-04       0 3.322482e+00
## 72     72                                                        Right Precuneus      31 0.19375000 2.497502e-01    0       0      0 7.708341e-06       0 7.140275e-02
## 73     73                                                Left Paracentral lobule       1 0.01886792 3.264002e-04    0       0      0 1.007408e-08       0 3.264002e-04
## 74     74                                               Right Paracentral lobule       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 75     75                                                   Left Caudate nucleus      28 0.75675676 1.499540e+00    0       0      0 4.628209e-05       0 6.526606e-01
## 76     76                                                  Right Caudate nucleus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 77     77                                        Left Lenticular nucleus-Putamen      54 1.00000000 4.070004e+01    0       0      0 1.256174e-03       0 4.204569e+00
## 78     78                                       Right Lenticular nucleus-Putamen       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 79     79                                       Left Lenticular nucleus-Pallidum      11 1.00000000 3.803091e+00    0       0      0 1.173794e-04       0 1.013942e+00
## 80     80                                      Right Lenticular nucleus-Pallidum       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 81     81                                                          Left Thalamus       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 82     82                                                         Right Thalamus       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 83     83                                                     Left Heschls gyrus      14 1.00000000 6.325236e+01    0       0      0 1.952233e-03       0 6.877505e+00
## 84     84                                                    Right Heschls gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 85     85                                           Left Superior temporal gyrus     150 1.00000000 2.973087e+02    0       0      0 9.176193e-03       0 6.196454e+00
## 86     86                                          Right Superior temporal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 87     87                            Left Temporal pole: superior temporal gyrus      67 1.00000000 1.842698e+00    0       0      0 5.687340e-05       0 2.115854e-01
## 88     88                           Right Temporal pole: superior temporal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 89     89                                             Left Middle temporal gyrus     247 1.00000000 1.489357e+02    0       0      0 4.596781e-03       0 3.752971e+00
## 90     90                                            Right Middle temporal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 91     91                              Left Temporal pole: middle temporal gyrus      35 1.00000000 2.670591e-01    0       0      0 8.242563e-06       0 4.321610e-02
## 92     92                             Right Temporal pole: middle temporal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 93     93                                           Left Inferior temporal gyrus     120 1.00000000 2.735250e+01    0       0      0 8.442131e-04       0 1.996966e+00
## 94     94                                          Right Inferior temporal gyrus       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 95     95                                   Left Crus I of cerebellar hemisphere     100 0.75757576 1.193042e+00    0       0      0 3.682229e-05       0 1.406105e-01
## 96     96                                  Right Crus I of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 97     97                                  Left Crus II of cerebellar hemisphere       3 0.03571429 1.822986e-05    0       0      0 5.626499e-10       0 6.250557e-06
## 98     98                                 Right Crus II of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 99     99                               Left Lobule III of cerebellar hemisphere       7 1.00000000 5.503356e+00    0       0      0 1.698567e-04       0 1.160132e+00
## 100   100                              Right Lobule III of cerebellar hemisphere       6 1.00000000 7.662559e-02    0       0      0 2.364987e-06       0 3.410214e-02
## 101   101                              Left Lobule IV-V of cerebellar hemisphere      57 1.00000000 3.741270e+01    0       0      0 1.154713e-03       0 1.880591e+00
## 102   102                             Right Lobule IV-V of cerebellar hemisphere      22 0.62857143 1.570715e-01    0       0      0 4.847887e-06       0 4.244862e-02
## 103   103                                Left Lobule VI of cerebellar hemisphere      74 1.00000000 1.056744e+01    0       0      0 3.261556e-04       0 6.981526e-01
## 104   104                               Right Lobule VI of cerebellar hemisphere       6 0.08823529 1.592300e-03    0       0      0 4.914505e-08       0 1.017942e-03
## 105   105                              Left Lobule VIIB of cerebellar hemisphere       3 0.12500000 9.149168e-04    0       0      0 2.823817e-08       0 8.037689e-04
## 106   106                             Right Lobule VIIB of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 107   107                              Left Lobule VIII of cerebellar hemisphere      17 0.24285714 1.404709e-02    0       0      0 4.335523e-07       0 5.640267e-03
## 108   108                             Right Lobule VIII of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 109   109                                Left Lobule IX of cerebellar hemisphere       8 0.25806452 1.616005e-02    0       0      0 4.987670e-07       0 9.674748e-03
## 110   110                               Right Lobule IX of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 111   111                                 Left Lobule X of cerebellar hemisphere       1 1.00000000 5.597982e-03    0       0      0 1.727772e-07       0 5.597982e-03
## 112   112                                Right Lobule X of cerebellar hemisphere       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 113   113                                                  Lobule I-II of vermis       1 1.00000000 7.959824e-02    0       0      0 2.456736e-06       0 7.959824e-02
## 114   114                                                   Lobule III of vermis       8 1.00000000 2.267892e+00    0       0      0 6.999668e-05       0 6.248655e-01
## 115   115                                                  Lobule IV-V of vermis      34 1.00000000 3.894355e+00    0       0      0 1.201961e-04       0 7.620944e-01
## 116   116                                                    Lobule VI of vermis      16 1.00000000 6.076200e-02    0       0      0 1.875370e-06       0 1.646879e-02
## 117   117                                                   Lobule VII of vermis       6 0.54545455 3.528699e-03    0       0      0 1.089105e-07       0 2.468348e-03
## 118   118                                                  Lobule VIII of vermis       5 0.50000000 3.548390e-03    0       0      0 1.095182e-07       0 2.781213e-03
## 119   119                                                    Lobule IX of vermis       3 0.42857143 8.760055e-04    0       0      0 2.703721e-08       0 8.215907e-04
## 120   120                                                     Lobule X of vermis       3 1.00000000 2.255844e-02    0       0      0 6.962480e-07       0 1.990642e-02
## 121   121                                    Left Thalamus-Anteroventral Nucleus       1 1.00000000 1.350460e-01    0       0      0 4.168086e-06       0 1.350460e-01
## 122   122                                   Right Thalamus-Anteroventral Nucleus       2 1.00000000 8.629559e-03    0       0      0 2.663444e-07       0 8.044917e-03
## 123   123                                                 Left Lateral posterior       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 124   124                                                Right Lateral posterior       3 1.00000000 2.297779e-02    0       0      0 7.091911e-07       0 1.557184e-02
## 125   125                                                  Left Ventral anterior       3 1.00000000 5.555910e-01    0       0      0 1.714787e-05       0 3.475474e-01
## 126   126                                                 Right Ventral anterior       1 0.20000000 3.770724e-04    0       0      0 1.163804e-08       0 3.770724e-04
## 127   127                                                   Left Ventral lateral      15 1.00000000 1.225426e+01    0       0      0 3.782180e-04       0 2.347056e+00
## 128   128                                                  Right Ventral lateral       8 0.72727273 6.158087e-03    0       0      0 1.900644e-07       0 4.478616e-03
## 129   129                                            Left Ventral posterolateral      12 1.00000000 3.992214e+01    0       0      0 1.232165e-03       0 5.808750e+00
## 130   130                                           Right Ventral posterolateral       5 0.41666667 5.039269e-03    0       0      0 1.555330e-07       0 1.906710e-03
## 131   131                                                      Left Intralaminar       4 1.00000000 7.303360e+00    0       0      0 2.254124e-04       0 2.250353e+00
## 132   132                                                     Right Intralaminar       3 1.00000000 6.681360e-02    0       0      0 2.062148e-06       0 3.244947e-02
## 133   133                                                          Left Reuniens       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 134   134                                                         Right Reuniens       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 135   135                                  Left Mediodorsal medial magnocellular       9 1.00000000 5.968962e+00    0       0      0 1.842272e-04       0 1.215673e+00
## 136   136                                 Right Mediodorsal medial magnocellular       9 1.00000000 7.136350e-01    0       0      0 2.202577e-05       0 1.772179e-01
## 137   137                                 Left Mediodorsal lateral parvocellular       2 1.00000000 1.709580e+00    0       0      0 5.276481e-05       0 1.350485e+00
## 138   138                                Right Mediodorsal lateral parvocellular       4 1.00000000 4.448508e-02    0       0      0 1.372996e-06       0 2.024112e-02
## 139   139                                                Left Lateral geniculate       1 1.00000000 3.964922e+00    0       0      0 1.223741e-04       0 3.964922e+00
## 140   140                                               Right Lateral geniculate       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 141   141                                                 Left Medial Geniculate       1 1.00000000 4.273022e+00    0       0      0 1.318834e-04       0 4.273022e+00
## 142   142                                                Right Medial Geniculate       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 143   143                                                 Left Pulvinar anterior       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 144   144                                                Right Pulvinar anterior       1 0.50000000 3.704953e-03    0       0      0 1.143504e-07       0 3.704953e-03
## 145   145                                                   Left Pulvinar medial      10 1.00000000 3.544561e+01    0       0      0 1.094000e-03       0 6.039709e+00
## 146   146                                                  Right Pulvinar medial       9 0.81818182 2.456256e-01    0       0      0 7.581036e-06       0 6.200280e-02
## 147   147                                                  Left Pulvinar lateral       3 1.00000000 8.792075e+00    0       0      0 2.713603e-04       0 3.534778e+00
## 148   148                                                 Right Pulvinar lateral       2 1.00000000 5.806060e-03    0       0      0 1.791994e-07       0 2.908921e-03
## 149   149                                                 Left Pulvinar inferior       1 1.00000000 5.285981e+00    0       0      0 1.631476e-04       0 5.285981e+00
## 150   150                                                Right Pulvinar inferior       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 151   151                               Left Anterior cingulate cortex-subgenual       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 152   152                              Right Anterior cingulate cortex-subgenual       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 153   153                               Left Anterior cingulate cortex-pregenual       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 154   154                              Right Anterior cingulate cortex-pregenual       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 155   155                           Left Anterior cingulate cortex-supracallosal       1 0.02564103 1.149136e-04    0       0      0 3.546718e-09       0 1.149136e-04
## 156   156                          Right Anterior cingulate cortex-supracallosal       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 157   157                                                 Left Nucleus accumbens       7 1.00000000 4.723677e-02    0       0      0 1.457925e-06       0 2.107174e-02
## 158   158                                                Right Nucleus accumbens       0 0.00000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 159   159                                            Left Ventral tegmental area       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 160   160                                           Right Ventral tegmental area       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 161   161                                    Left Substantia nigra-pars compacta       1 1.00000000 3.716791e-01    0       0      0 1.147158e-05       0 3.716791e-01
## 162   162                                   Right Substantia nigra-pars compacta       2 1.00000000 1.113302e-02    0       0      0 3.436118e-07       0 8.883362e-03
## 163   163                                  Left Substantia nigra-pars reticulata       4 1.00000000 2.914534e+00    0       0      0 8.995476e-05       0 1.300334e+00
## 164   164                                 Right Substantia nigra-pars reticulata       1 1.00000000 2.145111e-04    0       0      0 6.620714e-09       0 2.145111e-04
## 165   165                                                       Left Red nucleus       3 1.00000000 2.115039e+00    0       0      0 6.527899e-05       0 9.159293e-01
## 166   166                                                      Right Red nucleus       4 1.00000000 2.482625e-01    0       0      0 7.662423e-06       0 1.084301e-01
## 167   167                                                   Left Locus coeruleus       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 168   168                                                  Right Locus coeruleus       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 169   169                                                   Raphe nucleus-dorsal       1 1.00000000 5.300409e-01    0       0      0 1.635929e-05       0 5.300409e-01
## 170   170                                                   Raphe nucleus-median       0        NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 
## attr(,"class")
## [1] "atlastable"

The loading for the second component

Q = fit113$wbX[[1]][,2]
outstat1 = rec(Q, img1$imagedim, B=B1, mask=img1$brainpos)
outstat2 = -outstat1
coat(template, outstat2)

atlastable(tmpatlas, outstat2, atlasdataset)
## $table
##     ROIid                                                                ROIname sizenum     sizepct     sumvalue Min. 1st Qu. Median         Mean 3rd Qu.         Max.
## 1       1                                                  Left Precentral gyrus      60 0.319148936 6.385419e-01    0       0      0 1.970808e-05       0 1.433462e-01
## 2       2                                                 Right Precentral gyrus      85 0.467032967 1.926003e+00    0       0      0 5.944455e-05       0 1.679313e-01
## 3       3                               Left Superior frontal gyrus-dorsolateral      39 0.156000000 1.324599e-01    0       0      0 4.088268e-06       0 1.744149e-02
## 4       4                              Right Superior frontal gyrus-dorsolateral      63 0.257142857 1.351160e+00    0       0      0 4.170248e-05       0 1.497747e-01
## 5       5                                              Left Middle frontal gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 6       6                                             Right Middle frontal gyrus       7 0.028112450 1.936774e-02    0       0      0 5.977698e-07       0 1.308377e-02
## 7       7                             Left Inferior frontal gyrus-opercular part       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 8       8                            Right Inferior frontal gyrus-opercular part       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 9       9                            Left Inferior frontal gyrus-triangular part       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 10     10                           Right Inferior frontal gyrus-triangular part       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 11     11                                                Left IFG pars orbitalis       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 12     12                                               Right IFG pars orbitalis       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 13     13                                                Left Rolandic operculum      22 0.392857143 1.231418e+00    0       0      0 3.800674e-05       0 2.863178e-01
## 14     14                                               Right Rolandic operculum       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 15     15                                          Left Supplementary motor area      66 0.758620690 2.787698e+00    0       0      0 8.604008e-05       0 2.070768e-01
## 16     16                                         Right Supplementary motor area      90 0.849056604 9.594453e+00    0       0      0 2.961251e-04       0 3.159231e-01
## 17     17                                                  Left Olfactory cortex       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 18     18                                                 Right Olfactory cortex       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 19     19                                     Left Superior frontal gyrus-medial       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 20     20                                    Right Superior frontal gyrus-medial       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 21     21                             Left Superior frontal gyrus-medial orbital       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 22     22                            Right Superior frontal gyrus-medial orbital       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 23     23                                                      Left Gyrus rectus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 24     24                                                     Right Gyrus rectus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 25     25                                              Left Medial orbital gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 26     26                                             Right Medial orbital gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 27     27                                            Left Anterior orbital gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 28     28                                           Right Anterior orbital gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 29     29                                           Left Posterior orbital gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 30     30                                          Right Posterior orbital gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 31     31                                             Left Lateral orbital gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 32     32                                            Right Lateral orbital gyrus       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 33     33                                                            Left Insula      11 0.114583333 1.418258e-01    0       0      0 4.377340e-06       0 9.389534e-02
## 34     34                                                           Right Insula       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 35     35                           Left Anterior cingulate & paracingulate gyri       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 36     36                          Right Anterior cingulate & paracingulate gyri       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 37     37                             Left Middle cingulate & paracingulate gyri      84 0.893617021 3.524396e+01    0       0      0 1.087776e-03       0 5.265023e+00
## 38     38                            Right Middle cingulate & paracingulate gyri      80 0.816326531 6.559560e+00    0       0      0 2.024556e-04       0 4.413128e-01
## 39     39                                         Left Posterior cingulate gyrus      17 1.000000000 2.340084e+01    0       0      0 7.222482e-04       0 3.521056e+00
## 40     40                                        Right Posterior cingulate gyrus      11 1.000000000 2.407464e+00    0       0      0 7.430446e-05       0 7.584434e-01
## 41     41                                                       Left Hippocampus      11 0.250000000 2.137798e-01    0       0      0 6.598142e-06       0 8.066659e-02
## 42     42                                                      Right Hippocampus       1 0.022222222 3.744927e-05    0       0      0 1.155842e-09       0 3.744927e-05
## 43     43                                             Left Parahippocampal gyrus       7 0.170731707 4.851080e-03    0       0      0 1.497247e-07       0 1.558628e-03
## 44     44                                            Right Parahippocampal gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 45     45                                                          Left Amygdala       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 46     46                                                         Right Amygdala       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 47     47                          Left Calcarine fissure and surrounding cortex      89 1.000000000 4.533484e+01    0       0      0 1.399224e-03       0 2.301207e+00
## 48     48                         Right Calcarine fissure and surrounding cortex      83 0.855670103 5.167356e+00    0       0      0 1.594863e-04       0 5.326529e-01
## 49     49                                                            Left Cuneus      66 1.000000000 1.185381e+02    0       0      0 3.658584e-03       0 5.685272e+00
## 50     50                                                           Right Cuneus      79 0.987500000 1.647293e+01    0       0      0 5.084238e-04       0 1.075869e+00
## 51     51                                                     Left Lingual gyrus      90 0.947368421 3.306905e+00    0       0      0 1.020650e-04       0 3.884172e-01
## 52     52                                                    Right Lingual gyrus      62 0.632653061 5.955825e-01    0       0      0 1.838217e-05       0 2.219980e-01
## 53     53                                          Left Superior occipital gyrus      68 1.000000000 1.167450e+02    0       0      0 3.603241e-03       0 7.709361e+00
## 54     54                                         Right Superior occipital gyrus      56 0.823529412 4.994497e-01    0       0      0 1.541511e-05       0 5.536336e-02
## 55     55                                            Left Middle occipital gyrus     160 0.987654321 1.863647e+02    0       0      0 5.751997e-03       0 7.967722e+00
## 56     56                                           Right Middle occipital gyrus       3 0.027272727 3.191678e-04    0       0      0 9.850857e-09       0 2.662634e-04
## 57     57                                          Left Inferior occipital gyrus      31 0.659574468 2.694271e-02    0       0      0 8.315653e-07       0 6.630163e-03
## 58     58                                         Right Inferior occipital gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 59     59                                                    Left Fusiform gyrus      26 0.252427184 4.028398e-02    0       0      0 1.243333e-06       0 8.009797e-03
## 60     60                                                   Right Fusiform gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 61     61                                                 Left Postcentral gyrus     135 0.714285714 1.691043e+01    0       0      0 5.219268e-04       0 1.420441e+00
## 62     62                                                Right Postcentral gyrus      67 0.374301676 6.972058e-01    0       0      0 2.151870e-05       0 1.049028e-01
## 63     63                                           Left Superior parietal gyrus     122 1.000000000 3.224538e+02    0       0      0 9.952277e-03       0 7.645856e+00
## 64     64                                          Right Superior parietal gyrus      68 0.576271186 9.121250e-01    0       0      0 2.815201e-05       0 1.654363e-01
## 65     65  Left Inferior parietal gyrus-excluding supramarginal and angular gyri     123 1.000000000 1.798702e+02    0       0      0 5.551549e-03       0 6.837754e+00
## 66     66 Right Inferior parietal gyrus-excluding supramarginal and angular gyri       2 0.024390244 3.471351e-04    0       0      0 1.071405e-08       0 1.883311e-04
## 67     67                                               Left SupraMarginal gyrus      56 0.918032787 4.065460e+00    0       0      0 1.254771e-04       0 5.827098e-01
## 68     68                                              Right SupraMarginal gyrus       1 0.010752688 1.763923e-06    0       0      0 5.444207e-11       0 1.763923e-06
## 69     69                                                     Left Angular gyrus      67 1.000000000 1.200552e+02    0       0      0 3.705407e-03       0 6.088266e+00
## 70     70                                                    Right Angular gyrus       2 0.020408163 3.772943e-03    0       0      0 1.164489e-07       0 2.341176e-03
## 71     71                                                         Left Precuneus     132 1.000000000 3.072416e+02    0       0      0 9.482766e-03       0 7.466646e+00
## 72     72                                                        Right Precuneus     160 1.000000000 4.222704e+01    0       0      0 1.303304e-03       0 1.282177e+00
## 73     73                                                Left Paracentral lobule      53 1.000000000 4.682815e+00    0       0      0 1.445313e-04       0 4.062110e-01
## 74     74                                               Right Paracentral lobule      44 1.000000000 3.437726e+00    0       0      0 1.061027e-04       0 2.065649e-01
## 75     75                                                   Left Caudate nucleus       6 0.162162162 6.971127e-03    0       0      0 2.151582e-07       0 5.209895e-03
## 76     76                                                  Right Caudate nucleus      14 0.280000000 1.967139e-02    0       0      0 6.071415e-07       0 4.787706e-03
## 77     77                                        Left Lenticular nucleus-Putamen       1 0.018518519 1.748245e-05    0       0      0 5.395817e-10       0 1.748245e-05
## 78     78                                       Right Lenticular nucleus-Putamen       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 79     79                                       Left Lenticular nucleus-Pallidum       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 80     80                                      Right Lenticular nucleus-Pallidum       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 81     81                                                          Left Thalamus       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 82     82                                                         Right Thalamus       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 83     83                                                     Left Heschls gyrus       8 0.571428571 9.520539e-02    0       0      0 2.938438e-06       0 4.355492e-02
## 84     84                                                    Right Heschls gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 85     85                                           Left Superior temporal gyrus      57 0.380000000 3.125891e+00    0       0      0 9.647810e-05       0 3.858545e-01
## 86     86                                          Right Superior temporal gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 87     87                            Left Temporal pole: superior temporal gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 88     88                           Right Temporal pole: superior temporal gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 89     89                                             Left Middle temporal gyrus      86 0.348178138 1.687835e+01    0       0      0 5.209368e-04       0 1.572207e+00
## 90     90                                            Right Middle temporal gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 91     91                              Left Temporal pole: middle temporal gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 92     92                             Right Temporal pole: middle temporal gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 93     93                                           Left Inferior temporal gyrus       3 0.025000000 7.071638e-05    0       0      0 2.182604e-09       0 3.775154e-05
## 94     94                                          Right Inferior temporal gyrus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 95     95                                   Left Crus I of cerebellar hemisphere       1 0.007575758 6.192189e-07    0       0      0 1.911169e-11       0 6.192189e-07
## 96     96                                  Right Crus I of cerebellar hemisphere       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 97     97                                  Left Crus II of cerebellar hemisphere       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 98     98                                 Right Crus II of cerebellar hemisphere       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 99     99                               Left Lobule III of cerebellar hemisphere       2 0.285714286 6.496359e-05    0       0      0 2.005049e-09       0 6.051280e-05
## 100   100                              Right Lobule III of cerebellar hemisphere       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 101   101                              Left Lobule IV-V of cerebellar hemisphere      26 0.456140351 2.928493e-01    0       0      0 9.038558e-06       0 8.762974e-02
## 102   102                             Right Lobule IV-V of cerebellar hemisphere      10 0.285714286 5.891954e-03    0       0      0 1.818504e-07       0 2.567740e-03
## 103   103                                Left Lobule VI of cerebellar hemisphere      23 0.310810811 1.406813e-02    0       0      0 4.342014e-07       0 3.208548e-03
## 104   104                               Right Lobule VI of cerebellar hemisphere       2 0.029411765 5.748270e-06    0       0      0 1.774157e-10       0 4.450791e-06
## 105   105                              Left Lobule VIIB of cerebellar hemisphere       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 106   106                             Right Lobule VIIB of cerebellar hemisphere       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 107   107                              Left Lobule VIII of cerebellar hemisphere       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 108   108                             Right Lobule VIII of cerebellar hemisphere       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 109   109                                Left Lobule IX of cerebellar hemisphere       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 110   110                               Right Lobule IX of cerebellar hemisphere       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 111   111                                 Left Lobule X of cerebellar hemisphere       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 112   112                                Right Lobule X of cerebellar hemisphere       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 113   113                                                  Lobule I-II of vermis       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 114   114                                                   Lobule III of vermis       7 0.875000000 4.230594e-03    0       0      0 1.305739e-07       0 2.577779e-03
## 115   115                                                  Lobule IV-V of vermis      31 0.911764706 5.932546e-01    0       0      0 1.831033e-05       0 1.629019e-01
## 116   116                                                    Lobule VI of vermis      10 0.625000000 6.898923e-03    0       0      0 2.129297e-07       0 2.378809e-03
## 117   117                                                   Lobule VII of vermis       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 118   118                                                  Lobule VIII of vermis       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 119   119                                                    Lobule IX of vermis       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 120   120                                                     Lobule X of vermis       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 121   121                                    Left Thalamus-Anteroventral Nucleus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 122   122                                   Right Thalamus-Anteroventral Nucleus       1 0.500000000 1.249982e-04    0       0      0 3.857969e-09       0 1.249982e-04
## 123   123                                                 Left Lateral posterior       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 124   124                                                Right Lateral posterior       3 1.000000000 3.549411e-03    0       0      0 1.095497e-07       0 2.952804e-03
## 125   125                                                  Left Ventral anterior       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 126   126                                                 Right Ventral anterior       1 0.200000000 1.763923e-06    0       0      0 5.444207e-11       0 1.763923e-06
## 127   127                                                   Left Ventral lateral       4 0.266666667 1.116103e-03    0       0      0 3.444764e-08       0 5.891870e-04
## 128   128                                                  Right Ventral lateral       4 0.363636364 1.915057e-03    0       0      0 5.910669e-08       0 1.735941e-03
## 129   129                                            Left Ventral posterolateral       8 0.666666667 4.772350e-02    0       0      0 1.472947e-06       0 1.574355e-02
## 130   130                                           Right Ventral posterolateral       3 0.250000000 1.328130e-04    0       0      0 4.099166e-09       0 1.249982e-04
## 131   131                                                      Left Intralaminar       1 0.250000000 2.897462e-04    0       0      0 8.942783e-09       0 2.897462e-04
## 132   132                                                     Right Intralaminar       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 133   133                                                          Left Reuniens       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 134   134                                                         Right Reuniens       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 135   135                                  Left Mediodorsal medial magnocellular       3 0.333333333 1.683435e-03    0       0      0 5.195787e-08       0 1.441014e-03
## 136   136                                 Right Mediodorsal medial magnocellular       1 0.111111111 3.434015e-04    0       0      0 1.059881e-08       0 3.434015e-04
## 137   137                                 Left Mediodorsal lateral parvocellular       1 0.500000000 1.003863e-05    0       0      0 3.098344e-10       0 1.003863e-05
## 138   138                                Right Mediodorsal lateral parvocellular       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 139   139                                                Left Lateral geniculate       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 140   140                                               Right Lateral geniculate       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 141   141                                                 Left Medial Geniculate       1 1.000000000 4.856719e-04    0       0      0 1.498987e-08       0 4.856719e-04
## 142   142                                                Right Medial Geniculate       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 143   143                                                 Left Pulvinar anterior       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 144   144                                                Right Pulvinar anterior       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 145   145                                                   Left Pulvinar medial      10 1.000000000 3.709338e-01    0       0      0 1.144857e-05       0 9.919363e-02
## 146   146                                                  Right Pulvinar medial       4 0.363636364 3.513521e-04    0       0      0 1.084420e-08       0 2.532056e-04
## 147   147                                                  Left Pulvinar lateral       3 1.000000000 8.926384e-03    0       0      0 2.755057e-07       0 5.003917e-03
## 148   148                                                 Right Pulvinar lateral       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 149   149                                                 Left Pulvinar inferior       1 1.000000000 3.071638e-02    0       0      0 9.480364e-07       0 3.071638e-02
## 150   150                                                Right Pulvinar inferior       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 151   151                               Left Anterior cingulate cortex-subgenual       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 152   152                              Right Anterior cingulate cortex-subgenual       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 153   153                               Left Anterior cingulate cortex-pregenual       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 154   154                              Right Anterior cingulate cortex-pregenual       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 155   155                           Left Anterior cingulate cortex-supracallosal       5 0.128205128 1.779044e-02    0       0      0 5.490877e-07       0 1.122857e-02
## 156   156                          Right Anterior cingulate cortex-supracallosal       2 0.064516129 7.567588e-04    0       0      0 2.335675e-08       0 7.507080e-04
## 157   157                                                 Left Nucleus accumbens       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 158   158                                                Right Nucleus accumbens       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 159   159                                            Left Ventral tegmental area       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 160   160                                           Right Ventral tegmental area       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 161   161                                    Left Substantia nigra-pars compacta       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 162   162                                   Right Substantia nigra-pars compacta       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 163   163                                  Left Substantia nigra-pars reticulata       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 164   164                                 Right Substantia nigra-pars reticulata       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 165   165                                                       Left Red nucleus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 166   166                                                      Right Red nucleus       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 167   167                                                   Left Locus coeruleus       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 168   168                                                  Right Locus coeruleus       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 169   169                                                   Raphe nucleus-dorsal       0 0.000000000 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 170   170                                                   Raphe nucleus-median       0         NaN 0.000000e+00    0       0      0 0.000000e+00       0 0.000000e+00
## 
## attr(,"class")
## [1] "atlastable"

This is similar to the result from the sparse PCA (without supervision).

The following method can be used to plot the weights of several components simultaneously. It is first reconstructed in three dimensions with the multirec function and then plotted with the multicompplot function. It is set to display four columns per component.

ws = multirec(fit113, imagedim=img1$imagedim, B=B1, mask=img1$brainpos)
multicompplot(ws, template, col4comp=4)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.