wiki:TenthQuery

Version 1 (modified by detwiler, 11 years ago) (diff)

--

return to XbrainEvaluation

let $target_ant := -32
let $ant_dev := 5

let $target_sup := 18
let $sup_dev := 5

let $target_right := 59
let $right_dev := 5

let $inverse :=
dxq:csm("
<results>
<TransformServerParam coord='magnet_coordinates' source='0' target=''/>
{
for $p in $root/patient
return  
     <patient>
     {$p/pnum}
     {$p/viq}
     {$p/sex}
     <age>{$p/age_at_registration/text()}</age> 
     {
      for $s in $p/surgery
      return 
      <surgery>
      {
       for $site in $s/stimsite
       let $oid := $site/_oid
       return
       <stimsite>
              { $site/surgery}
              { $site/type}
              {$site/site_label}
              { 
                for $sitemap_elt in $p/surgery/sitetoanatomymap[preference='1']/sitetoanatomymapelement[stimsite/_oid = $oid]
                return    
                  <magnet_coordinates x0='{$sitemap_elt/ant_coord/text()}' y0='{$sitemap_elt/sup_coord/text()}' 
                      z0='{$sitemap_elt/right_coord/text()}' space0='P{$p/pnum}' space='MNI'>
                      <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[stimsite/_oid = $oid]
                return    
                  <anatomical_name>{$anat_elt/term/fullname/text()}</anatomical_name>
              }   
              {
                 for $trialcode in $p//trial[stimsite1/_oid = $oid][stimulated='Y']/trialcode/term[type='CSM error code']/abbrev
                 return 
                 <trialcode>
                     {$trialcode/text()}
                 </trialcode>
             }
       </stimsite>
      }
      </surgery>
     }
     </patient>
}
</results>
")

let $patients_trans := dxq:trans($inverse)

return 
<results>
{
for $patient in $patients_trans//patient
let $sites_in_region :=
    for $stimsite in $patient/surgery/stimsite
    let $ant := number($stimsite//magnet_coordinates/@x)
    let $sup := number($stimsite//magnet_coordinates/@y)
    let $right := number($stimsite//magnet_coordinates/@z)
    where (exists($stimsite/trialcode) and $target_ant - $ant_dev lt $ant) and ($ant lt $target_ant + $ant_dev) and 
        ($target_sup - $sup_dev lt $sup) and ($sup lt $target_sup + $sup_dev) and 
        ($target_right - $right_dev lt $right) and ($right lt $target_right + $right_dev)    
    return
        $stimsite
where(exists($sites_in_region))
return
<patient>
{$patient/pnum}
{$sites_in_region}
</patient>
}
</results>