Overview

# xnat4clj
Copyright (c) 2010,2011 Washington University
Author: Kevin A. Archie <karchie@wustl.edu>

Clojure client tools for XNAT

To use:

1. Make a local copy of this package.
  $ hg clone https://bitbucket.org/karchie/xnat4clj

2. Install Leiningen, the Clojure build utility:

  $ wget https://raw.github.com/technomancy/leiningen/stable/bin/lein
  $ mv lein ~/bin           # or somewhere else in your $PATH
  $ chmod 755 ~/bin/lein    # make it executable

3. Download the dependencies:

  $ cd ~/xnat4clj  # or wherever you put this source tree
  $ lein deps      # go get coffee while lein downloads the internet

4. Start the Clojure environment:

  $ lein repl
  REPL started; server listening on localhost port nnnn
  user=>

5. Load the XNAT client tools and switch to their namespace:

  user=> (load-file "src/nrg/xnat.clj")
  #'nrg.xnat/with-xnat
  user=> (in-ns 'nrg.xnat)
  #<Namespace nrg.xnat>
  nrg.xnat=>

6. Set the XNAT URL and your username and password:

  nrg.xnat=> (def xnat (open-xnat "http://my.xnat.org" "username" "password"))
  nil
  nrg.xnat=>

7. Run the required functions. Some examples follow.

To re-extract data from all DICOM files in a session:

  nrg.xnat=> (pull-data-from-headers! xnat "project" "subject" "session"))
  project / subject / session : MyXNAT_E2015 -> 200

     ^         ^         ^            ^          ^
  project   subject   session    experiment  HTTP status
   label     label     label         ID         code

If the session label is omitted, re-extraction will run for all
sessions for the provided project and subject. Similarly, if the
subject and session labels are omitted, re-extraction will run for all
subjects and sessions in the provided project. If no labels are
provided, re-extraction will run for all experiments in all projects.

Documentation for any function can be obtained by doing:

  nrg.xnat=> (use 'clojure.repl)   # only need to do this once
  nil
  nrg.xnat=> (doc pull-data-from-headers!)
  -------------------------
  nrg.xnat/pull-data-from-headers!
  ([xnat project subject experiment] [xnat project subject] [xnat project])
    Pull metadata from headers for the given project, subject and
  ...

Over 30 functions are defined in nrg.xnat; some of the easiest to use
include:

get-project-ids
get-project-aliases
get-subjects
get-experiments

There are also a variety of functions that retrieve and operate on
session and catalog XMLs. Look through src/nrg/xnat.clj for details.