Command-line interface

check

Implementation of CLI check command.

treem.commands.check.check(args)[source]

Checks morphology reconstruction for structural consistency.

usage: swc check [-h] [-q] [-o <str>] file

positional arguments:
  file        input morphology file (swc)

optional arguments:
  -h, --help  show this help message and exit
  -q          disable output
  -o <str>    save output to file (json)

prints out error codes and IDs of error nodes; returns the number of errors

convert

Implementation of CLI convert command.

treem.commands.convert.convert(args)[source]

Converts input data to compliant SWC format.

usage: swc convert [-h] [-p <int> [<int> ...]] [-o <str>] [-q] file

positional arguments:
  file                  input morphology file (swc)

optional arguments:
  -h, --help            show this help message and exit
  -p <int> [<int> ...]  point type {1,2,3,4} [all]
  -o <str>              converted morphology file (swc) [inp.swc]
  -q                    disable output

find

Implementation of CLI find command.

treem.commands.find.find(args)[source]

Locates single nodes in morphology reconstruction.

usage: swc find [-h] [-p <int> [<int> ...]] [-e <int> [<int> ...]]
                [-b <int> [<int> ...]] [-g <int> [<int> ...]] [-d <float>]
                [-l <float>] [-i <float>] [-s <float>] [-z <float>]
                [--comp <str>] [-c <float>] [--bottom-up] [--cut-find]
                [--cut-find-iter <int>] [-n <int> [<int> ...]] [--sec]
                [--stem]
                file

positional arguments:
  file                  input morphology file (swc)

optional arguments:
  -h, --help            show this help message and exit
  -p <int> [<int> ...]  point type {1,2,3,4} [any]
  -e <int> [<int> ...]  branch order
  -b <int> [<int> ...]  branch breadth
  -g <int> [<int> ...]  node degree
  -d <float>            diameter threshold, um
  -l <float>            segment length threshold, um
  -i <float>            distance to root threshold, um
  -s <float>            virtual slice threshold (z axis), um
  -z <float>            z-jump threshold, um
  --comp <str>          comparison condition for threshold {lt,eq,gt} [gt]
  -c <float>            cut plane thickness, um (z axis)
  --bottom-up           slice surface down (z axis)
  --cut-find            find cut plane
  --cut-find-iter <int>
                        number of iterations [800]
  -n <int> [<int> ...]  branch nodes
  --sec                 section start ids only
  --stem                stem ids only

prints out point ids

measure

Implementation of CLI measure command.

treem.commands.measure.get_morphometry(reconstruction, args)[source]

Computes morphometric features of a reconstruction.

treem.commands.measure.measure(args)[source]

Computes morphometric features of multiple reconstructions.

usage: swc measure [-h] [-p <int> [<int> ...]] [-a <str> [<str> ...]]
                   [--sholl-res <float>] [--sholl-proj <str>] [-o <str>]
                   file [file ...]

positional arguments:
  file                  input morphology file (swc)

optional arguments:
  -h, --help            show this help message and exit
  -p <int> [<int> ...]  point type {1,2,3,4} [all]
  -a <str> [<str> ...]  optional feature {path,sec,seg,sholl}
  --sholl-res <float>   sholl sampling resolution, um [10.0]
  --sholl-proj <str>    sholl projection {xy,xz,yz} [3d]
  -o <str>              output morphometric file (json)

modify

Implementation of CLI modify command.

treem.commands.modify.modify(args)[source]

Modifies selected parts of morphology reconstruction.

usage: swc modify [-h] [-p <int> [<int> ...]] [-e <int> [<int> ...]]
                  [-b <int> [<int> ...]] [-i <int> [<int> ...]]
                  [-s <float> <float> <float>] [-r <float>] [-t <float>]
                  [-m <int>] [-j <float>] [--sec] [-w <float>] [-u] [-a]
                  [--seed <int>] [-o <str>]
                  file

positional arguments:
  file                  input morphology file (swc)

optional arguments:
  -h, --help            show this help message and exit
  -p <int> [<int> ...]  point type {1,2,3,4} [all]
  -e <int> [<int> ...]  branch order
  -b <int> [<int> ...]  branch breadth
  -i <int> [<int> ...]  input ids
  -s <float> <float> <float>
                        scaling factors, positive (x,y,z axes)
  -r <float>            radius scaling factor, positive
  -t <float>            stretching strength, rel.
  -m <int>              smoothing strength, iter.
  -j <float>            random coordinate jitter, um (max)
  --sec                 apply jitter per section
  -w <float>            random branch twisting, deg. (max)
  -u                    prune branches
  -a                    swap two random branches (from the list supplied to
                        -i)
  --seed <int>          random seed
  -o <str>              output morphology file (swc) [mod.swc]

render

Implementation of CLI render command.

class treem.commands.render.App(morph, title='render')[source]

Interactive application.

display()[source]

Display callback function.

genlist_lines(morph)[source]

Create display list for lines.

genlist_nodes(morph)[source]

Create display list for nodes.

genlist_points(morph)[source]

Create display list for points.

genlist_segments(morph)[source]

Create display list for segments.

keyboard(key, x, y)[source]

Keyboard callback function.

run()[source]

Enter event processing loop.

set_nrncolor(objtype)[source]

Change current color.

write_img()[source]

Save image buffer to file.

class treem.commands.render.InteractionMatrix[source]

Class for object rotation and translation.

add_rotation(angle, x, y, z)[source]

Rotate scene around a vector.

add_translation(x, y, z)[source]

Shift scene by a vector.

get_current_matrix()[source]

Return current matrix.

reset()[source]

Reset current matrix.

class treem.commands.render.MouseInteractor(translation_scale=0.1, rotation_scale=0.2)[source]

Class for mouse control.

apply()[source]

Apply matrix manipulations.

mouse_button(button, mode, x, y)[source]

Detect button press.

mouse_motion(x, y)[source]

Detect mouse motion.

treem.commands.render.render(args)[source]

Shows 3D model of morphology reconstruction.

usage: swc render [-h] file

positional arguments:
  file        input morphology file (swc)

optional arguments:
  -h, --help  show this help message and exit

interactive commands:
    mouse left drag         rotate
    mouse right drag        translate

    Z/z     zoom in/out
    w       white background
    b       black background
    d       dark background
    p       show/hide points
    l       show/hide lines
    n       show/hide nodes
    s       show/hide segments
    W       write image to file
    q       quit
    h/?     help message

repair

Implementation of CLI repair command.

treem.commands.repair.repair(args)[source]

Corrects morphology reconstruction at the given nodes.

usage: swc repair [-h] [-n] [-t <float> <float> <float>]
                  [-a <float> <float> <float>] [-k <float>] [-kxy <float>]
                  [--bottom-up] [--seed <int>] [-c <int> [<int> ...]]
                  [--force-repair] [--graft-point-type {2,3,4}] [--del-branch]
                  [--keep-radii] [-d <int> [<int> ...]] [--diam <str>]
                  [--diam-value <float>] [--pool <str> [<str> ...]]
                  [-l <int> [<int> ...]] [-z <int> [<int> ...]]
                  [--zjump <str>] [-f <str> [<str> ...]] [-r <float>]
                  [-o <str>] [-v]
                  file

positional arguments:
  file                  input morphology file (swc)

optional arguments:
  -h, --help            show this help message and exit
  -n                    center root
  -t <float> <float> <float>
                        translate morphology, um (x,y,z)
  -a <float> <float> <float>
                        rotate morphology, deg. (x,y,z axes)
  -k <float>            shrinkage correction factor (z axis)
  -kxy <float>          shrinkage correction factor (x,y plane)
  --bottom-up           slice surface down (z axis)
  --seed <int>          random seed
  -c <int> [<int> ...]  cut points ids (not compatible with -l)
  --force-repair        repair cuts using branches of any order
  --graft-point-type {2,3,4}
                        point type of a branch to graft onto a soma node
                        {2,3,4} [3]
  --del-branch          delete cut branches before repair
  --keep-radii          do not scale radii of repaired branches
  -d <int> [<int> ...]  set diameter in points ids
  --diam <str>          correction mode {joint,sec,order,breadth,value}
                        [joint]
  --diam-value <float>  diameter value, um [1.0]
  --pool <str> [<str> ...]
                        reference reconstructions for repair
  -l <int> [<int> ...]  delete nodes in points ids (not compatible with -c)
  -z <int> [<int> ...]  z-jump points ids
  --zjump <str>         correction mode {align,split,tilt,join} [align]
  -f <str> [<str> ...]  flip along axis {x,y,z}
  -r <float>            sampling resolution, um
  -o <str>              output morphology file (swc) [rep.swc]
  -v                    verbose output

view

Implementation of CLI view command.

treem.commands.view.view(args)[source]

Display neuron morphology structure.

usage: swc view [-h] [-p <int> [<int> ...]] [-b <int> [<int> ...]]
                [-s <int> [<int> ...]] [-m <int> [<int> ...]] [--show-id]
                [-t <str>] [--no-axes] [--scale <float>] [-c <str>]
                [--shadow-color <str>] [--shadow-width <float>]
                [--line-width <float>] [--set-color <str> [<str> ...]]
                [-a <float> <float>] [-x <float> <float>] [-y <float> <float>]
                [-z <float> <float>] [--font <int>] [--title-font <int>] [-g]
                [--dgram-ystep <float>] [--dgram-zstep <float>] [-j <str>]
                [-o <str>]
                file [file ...]

positional arguments:
  file                  input morphology file (swc)

optional arguments:
  -h, --help            show this help message and exit
  -p <int> [<int> ...]  point type {1,2,3,4} [all]
  -b <int> [<int> ...]  branch start id
  -s <int> [<int> ...]  section start id
  -m <int> [<int> ...]  marker point id
  --show-id             show id labels
  -t <str>              set figure title
  --no-axes             disable axes
  --scale <float>       show scale bars, um
  -c <str>              color mode {neurites,cells,shadow} [neurites]
  --shadow-color <str>  shadow color [lightgray]
  --shadow-width <float>
                        shadow width [3.0]
  --line-width <float>  line width [1.0]
  --set-color <str> [<str> ...]
                        set color (number:colorname)
  -a <float> <float>    initial rotation angles, deg. (elevation, azimuth)
  -x <float> <float>    set limits for x-axis (min, max) [auto]
  -y <float> <float>    set limits for y-axis (min, max) [auto]
  -z <float> <float>    set limits for z-axis (min, max) [auto]
  --font <int>          font size [8]
  --title-font <int>    title font size [14]
  -g                    show as dendrogram graph
  --dgram-ystep <float>
                        change breadth step size in y-axis [auto]
  --dgram-zstep <float>
                        change breadth step size in z-axis [auto]
  -j <str>              projection {xy,xz,yz}
  -o <str>              save image to file