## Note: This page was created with the CommandTemplate
##
## If you're modifying this page please take a look at the
## latest version of CommandTemplate to ensure that you're
## using the latest version of the CommandTemplate
##
## See HelpOnCommandTemplate for description of formatting

'''Index'''
<<TableOfContents>>


= Name =
[[roisummary-sess]] - outputs data from [[func2roi-sess]] in ASCII format

= Synopsis =
[[roisummary-sess]] -sumfile <filename> -roidef <roidefname> -analysis <analysisname> -s <subjectname> or -sf <subjectfilename> -d <directory>

= Arguments =
== Positional Arguments ==
|| none ||

== Required Flagged Arguments ==
|| -sumfile filename || name of file in which to store the summary ||
|| -roidef   name || name of ROI definition ||
|| -analysis name || source is averaged data from analysis ||
|| -sf sessidfile  ... ||
|| -s  sessid      ... ||
|| -df srchdirfile ... ||
|| -d  srchdir     ... ||

== Optional Flagged Arguments ==
|| -transpose     || put sessid info on a row instead of a col ||
|| -excludesessid || do not include sess id in table ||
 
= Description =
Often, one wants to pool all the ROI averages across sessions into a
single table so that they can be read into a statistics package for
more elaborate analysis.  The results from [[func2roi-sess]] can be
collected into such a table using [[roisummary-sess]], which has the
following options:

Use '''-sumfile''' to specify the name of the file in which to store
the ascii results.  The ROI is specified with '''-roidef'''.  Without
any other options, [[roisummary-sess]] will get the ROI results from
each session and store them into the summary file. Each session will
have its own column, and each row represents a different measurement
according to the following scheme as outlined in '''Outputs'''.

= Outputs =

1. '''session id''' - text identifier of the session

2. '''nlabel''' - number of functional voxels in the structural label
regardless of whether they met the functional criteria.

3. '''nroi''' -  number of functional voxels in the final mask (ie,
ones that met the structural and functional criteria.

4. '''offset''' - mean functional baseline offset within the ROI (good for
computing percent signal changes)

5. '''eresstd''' - standard deviation of the residual error. This is
a measure of the variance left unexplained by the task.

6. '''DOF''' - degrees of freedom in eresstd. This can be used to
asses whether there is a difference among the sessions in the DOF as
could happen if some runs were excluded in some sessions and not in
others. 

7. '''TER''' - temporal resolution (in seconds) of the hemodynamic
estimation.  This is not a data value. This value is set at the time
of [[mkanalysis-sess.new]] and is included here to facilitate plotting
the results that follow. All sessions should have the same value.

8. '''tPreStim''' - time (in seconds) of the prestimulus baseline used
in hemodynamic estimation.  This is not a data value. This value is
set at the time of [[mkanalysis-sess.new]] and is included here to
facilitate plotting the results that follow. All sessions should have
the same value.

9. '''nconditions''' - number of conditions (excluding null
condition). All sessions should have the same value.

10. '''nestspercond''' - number of estimates per conditions. For block
analyses, this will have a value of 1. For event-related analyses, the
value will equal to the number of points in the time window.

11. There will be nconditions times nestspercond numbers starting
at this row.  The first set of nestspercond numbers are the values for the
first condition, the second set of nestspercond numbers are the
values for the second condition, etc.  Percent signal change can be
obtained by dividing these numbers by offset and multiplying by 100.


The format of this table can be modified slightly with the
'''-transpose''' and excludesessid flags. The 
'''-transpose''' flag creates the same table except that the data for the
session is placed on a row instead of in a column. The 
'''-excludesessid''' flag will eliminate the session id row from the
data. The '''-excludesessid'''' is provided because some software does
not allow data tables with text and numbers.

= Examples =
== Example 1: Per-Session Label and Functional Mask ==

Let's say that you have two sessions, s1 and s2, for which you have
already run individual event-related analyses (main2) as well as a
contrast (allvfix). The analysis has 2 conditions, with TER=TR=2sec 
tPreStim=4sec, and Time Window=18sec. The allvfix contrast gives
you an indication of which voxels are activated by the overall task.
A neuroanatomist has graciously labeled the fusiform and striate
regions of each subjects' brain giving you a total of 4 label files.
You create a directory in s1 called labels and put the
fusiform.label and striate.label for subject 1 into this
directory. You create a directory in s2 called labels and put the
fusiform.label and striate.label for subject 2 into this directory.

=== Subsection a: Fusiform with Positive Activation ===

[[func2roi-sess]] -roidef fusi-avf-pos-2 -analysis main2
-sesslabel fusiform -maskcontrast allvfix -maskthresh 2
-masktail pos -maskmap minsig -s s1 -s s2 -d . 

This will create an ROI named fusi-avf-pos-2  which uses the
fusiform.label in each subjects' labels directory along with the
allvfix contrast as the functional constraint.  Only voxels inside the
pre-defined fusiform label that exceed a significance of 10^-2 in
the minsig map and are positively correlated with the task will be
selected.  Once the final ROI is determined from the functional and
structural constraints, [[func2roi-sess]] will average the ROI voxels
from the main2 analysis together, and create a directory called
fusi-avf-pos-2 under main2 (in each session).

At this point, there are four things you can do next: (1) pool the
data into a text file, (2) view the hemodynamic response in the ROI
for each session, (3) view the final mask, or (4) inter-subject
average. 

'''Pooling the data into a text file'''

Here you will run [[roisummary-sess]] to create a text file of all the ROI data for
both session 1 and 2. 

[''roisummary-sess''] -sumfile fusi-avf-pos-2.dat -roidef fusi-avf-pos-2 -analysis main2 -s s1 -s s2 -d .

This will create a file called fusi-avf-pos-2.dat in which you
will find two columns.  The contents will look something like the
following (not including the text after the #'s): 

|| s1 ||  s2         || # session identifiers ||
||480  ||     467       ||  # number of functional voxels in the fusiform ||
|| 127  ||     177    ||   # number of active voxels ||
||1117.06 ||  1242.86 ||   # average baseline activity ||
|| 8.24   ||   7.29   ||     # std dev of residual error ||
|| 574   ||    574     ||    # DOF ||
|| 2.0   ||    0.1   ||      # TER = TR/20 ||
|| 4.0   ||    4.0   ||      # tPreStim ||
|| 3   ||      3     ||      # number of conditions ||
|| 9    ||     9    ||       # number of estimates per condition ||
|| 0.1746  ||  -1.5937   ||  # condition 1,  4 sec before stimulus onset ||
|| -0.1867  || -1.4410  ||   # condition 1,  2 sec before stimulus onset ||
|| 0.7258 ||   0.5711   ||  # condition 1,  stimulus onset ||
|| -0.2199  || -0.2157  ||   # condition 1,  2 sec after stimulus onset ||
|| 3.1832  ||  1.1900  ||   # condition 1,  4 sec after stimulus onset ||
|| 0.4660 ||   1.1168  ||   # condition 1,  6 sec after stimulus onset ||
|| 0.3595 ||   0.8347  ||   # condition 1,  8 sec after stimulus onset ||
|| 1.1501  ||  1.3319  ||   # condition 1, 10 sec after stimulus onset ||
|| 0.0847  ||  0.6813  ||   # condition 1, 12 sec after stimulus onset ||
|| -0.0956  ||  1.1908  ||   # condition 2,  4 sec before stimulus onset ||
|| -0.8323 ||  -1.2025   ||  # condition 2,  2 sec before stimulus onset ||
|| 0.2944  || -0.0198   ||  # condition 2,  stimulus onset ||
|| -0.9678  ||  0.0275   ||  # condition 2,  2 sec after stimulus onset ||
|| 1.7143  || -1.1041   ||  # condition 2,  4 sec after stimulus onset ||
|| 2.2259  ||  0.5585  ||   # condition 2,  6 sec after stimulus onset ||
|| -0.4462 ||  -0.9337  ||   # condition 2,  8 sec after stimulus onset ||
|| 0.9413  ||  1.4568   ||  # condition 2, 10 sec after stimulus onset| ||
|| 1.2794 ||  -0.7924  ||   # condition 2, 12 sec after stimulus onset ||

= Bugs =
None

= See Also =
[[func2roi-sess]]

= Links =
FreeSurfer, FsFast

= Methods Description =

= References =
[[References/Lastname###]]

= Reporting Bugs =
Report bugs to <analysis-bugs@nmr.mgh.harvard.edu>

= Author/s =
DougGreve PhD