wiki:MsXBrain_File

Version 5 (modified by ebmoore, 11 years ago) (diff)

--

File Directive in MsXBrain

Overview

MsXBrain can take a tag called File with a uri that points somewhere on the system (ie <File>file:/path/to/your/file</File>. For a file to properly display in the library, it must exist in a known library file. This is because there is a fair bit of meta-data (at least coordinate space, subject, study, modality and type) attached to each node and the goal was to keep the directive simple.

Known library files and subjects are both stored in the subjects.xml file (which lives at /usr/local/data/data11/hbp/subjects.xml). One consequence of this is that files don't cross libraries very well (i.e. requesting an hbp fMRI on an autism subject will result in the file not being well placed in the library).

Sample

No labels

xbrain

<results>
<!-- File directive.  Causes MindSeer to display the given uri.  For files 'file:' is required. -->
<File>file:/usr/local/data/data11/hbp/P178/spm/stats/S101/results_P178_sess1_hbp-3-3-norm/spmF_0001.hdr</File>
</results>

With labels

xbrain

<results>
<!-- File directive.  Causes MindSeer to display the given uri.  For files 'file:' is required. -->
<File>file:/usr/local/data/data11/hbp/P178/spm/stats/S101/results_P178_sess1_hbp-3-3-norm/spmF_0001.hdr</File>
{
dxq:csm("
<labels>
{
 let $code := '2'
 for $p in $pv/patient
 let $csm:=$p/surgery/csmstudy 
 where $csm/trial[stimulated='Y']/trialcode/term[type='CSM error code']/abbrev/text()=$code

 return 
 <patient> 
  {$p/pnum} 
  {$p/sex} 
  <age>{$p/age_at_registration/text()}</age> 
  {$p/viq} 
  { 
    for $t in $csm/trial 
    where $t[stimulated='Y']/trialcode/term[type='CSM error code']/abbrev/text()=$code 
    return
      <trial>
      {$t/trial_num}
      {
        for $tc in $t/trialcode
        return
          <code>{$tc/term/abbrev/text()}</code>
      }
      {
        for $site in $t/stimsite1
        return
        <stimsite>
          {$site/site_label}
          { 
            for $sitemap_elt in $p/surgery/sitetoanatomymap[preference='1']/sitetoanatomymapelement
            where $sitemap_elt/stimsite/_oid/text() = $t/stimsite1/_oid/text() 
            return    
              <magnet_coordinates>
                <ant_coord>{$sitemap_elt/ant_coord/text()}</ant_coord>
                <sup_coord>{$sitemap_elt/sup_coord/text()}</sup_coord>
                <right_coord>{$sitemap_elt/right_coord/text()}</right_coord>
              </magnet_coordinates>
          }    
          { 
            for $anat_elt in $p/surgery/anatomytonamemap[preference='1']/anatomytonamemapelement 
            where $anat_elt/stimsite/_oid/text() = $t/stimsite1/_oid/text() 
            return    
              <anatomical_name>{$anat_elt/term/fullname/text()}</anatomical_name>
          }    
        </stimsite>
      }
     </trial>
  }
  </patient>
 } 
</labels>
")
}
</results>

Finding Files

The easiest way to find interesting files is by using the MindSeer Library service at http://cuboid.biostr.washington.edu:8080/DataSet. The format for this file is described here Library File

Subjects.xml

To generate the subjects file, I use an xquery that extracts subjects information from a library xml file. The file and other xqueries lives in ~ebmoore/xqueries. There is also a script to update both library xml files and extract the subjects.xml file in that directory (make-all.sh).

(:
Extract patient and surfaces from a workspace to produce a subjects file
that can be used by MsDXBrain.

	Target schema
	<Subjects>
		<Subject name="" restricted="true/false" remote="true/false">
			<DataSet file=""/>
			<Cortex file=""/>
		</Subject>
	</Subjects>
:)

declare function local:make-node(
	$root as node(),
	$study as xs:string,
	$file as xs:string) as node()*
{
	for $patient in $root//Node[Tags/Coordinate_Space = "MNI" and Tags/Modality = "Cortex" and Tags/Study = $study]/Tags/Subject
	let $patient-nodes := $root//Node[Tags/Coordinate_Space = "MNI" and Tags/Type = "Structural" and Tags/Subject = $patient]
	order by $patient ascending
	return
		<Subject name="{$patient}" restricted="true" remote="true">
			<DataSet file="{$file}"/>
			{
				for $node in $patient-nodes
				let $file := $node/FileSet/URI[1]/text()
				let $cortex := $node/Tags/Modality = "Cortex"
				return
				<File launch="{$cortex}" file="{$file}"/>
			}
		</Subject>
};

let $root := doc("all-library.xml")
return
<Subjects>
	<Subject name="Average Gray*" restricted="false" remote="false">
		<DataSet file="surf/surfaces.bvx"/>
		<File launch="true" file="surf/surf_gray.off.gz"/>
	</Subject>
	<Subject name="Colin*" restricted="false" remote="false">
		<DataSet file="surf/surfaces.bvx"/>
		<File launch="true" file="surf/surf_Colin.mat.gz"/>
	</Subject>
{
	local:make-node($root, "hbp", "file:/usr/local/data/data11/hbp/ms_dataset.bvx")
}
{
	local:make-node($root, "autism", "file:/usr/local/data/data12/autism/ms_dataset.bvx")
}
</Subjects>