将lh/rh z-score向量转换为freesurfer labelmap

z2labelmap的Python项目详细描述


https://badge.fury.io/py/z2labelmap.svghttps://travis-ci.org/FNNDSC/z2labelmap.svg?branch=masterhttps://img.shields.io/badge/python-3.5%2B-blue.svg

Abstract

zlabelmap.py从z-score向量文件生成freesurfer labelmaps。freesurfer使用这些labelmap文件来对分割的大脑区域进行颜色编码。通过计算z-score到labelmap变换,我们能够显示不同于某些比较参考的热图和高亮度脑区,如下所示

https://github.com/FNNDSC/pl-z2labelmap/wiki/images/subj1-heatmap/frame126.png

如果一个分割的大脑区域的正体积偏差显示为红色(即受试者在该区域的体积大于参考值),而负体积偏差显示为蓝色(即受试者在该区域的体积小于参考值)。

请注意,这些是随机生成的z分数,纯粹是为了说明

实际上,脚本使用的输入文本向量文件是

<str_structureName> <float_lh_zScore> <float_rh_zScore>

例如,

G_and_S_frontomargin     ,1.254318450576827,-0.8663546810093861
G_and_S_occipital_inf    ,1.0823728865077271,-0.7703944006354377
G_and_S_paracentral      ,0.20767669866335847,2.9023126278939912
G_and_S_subcentral       ,2.395503357157743,-1.4966482475891556
G_and_S_transv_frontopol ,-1.7849555258577423,-2.461419463760234
G_and_S_cingul-Ant       ,-2.3831737860960382,1.1892593438667625
G_and_S_cingul-Mid-Ant   ,0.03381695289572084,-0.7909116233500506
G_and_S_cingul-Mid-Post  ,-2.4096082230335485,1.166457973597625
                          ...
                          ...
S_postcentral            ,1.3277159068067768,-1.4042773812503526
S_precentral-inf-part    ,-1.9467169777576718,1.7216636236995733
S_precentral-sup-part    ,0.764673539853991,2.1081570332369504
S_suborbital             ,0.522368665639954,-2.3593237820349007
S_subparietal            ,-0.14697262729901928,-2.2116605141889094
S_temporal_inf           ,-1.8442944920810271,-0.6895142771486307
S_temporal_sup           ,-1.8645248463693804,2.740099589311164
S_temporal_transverse    ,-2.4244451521560073,2.286596403222344

并创建一个freesurfer labelmap,其中<str_structureName>颜色对应于z-score(规格化在0到255之间)。

目前,仅完全支持aparc.a2009sfreesurfer分段,但计划将来支持分段。

阴性z-评分和阳性z-评分的处理方式相同,但有特定的标志颜色规范。正的和负的z-scores可以指定一些字符RGB的组合,以指示哪个颜色维度将反映z-scores。例如,a

--posColor R --negColor RG

将指定正的z分数阴影为red,负的z分数阴影为yellow(红色+绿色=黄色)。

Synopsis

python z2labelmap.py                                            \
    [-v <level>] [--verbosity <level>]                          \
    [--random] [--seed <seed>]                                  \
    [-p <f_posRange>] [--posRange <f_posRange>]                 \
    [-n <f_negRange>] [--negRange <f_negRange>]                 \
    [-P <'RGB'>] [--posColor <'RGB'>]                           \
    [-N  <'RGB'>] [--negColor <'RGB'>]                          \
    [--imageSet <imageSetDirectory>]                            \
    [-s <f_scaleRange>] [--scaleRange <f_scaleRange>]           \
    [-l <f_lowerFilter>] [--lowerFilter <f_lowerFilter>]        \
    [-u <f_upperFilter>] [--upperFilter <f_upperFilter>]        \
    [-z <zFile>] [--zFile <zFile>]                              \
    [--version]                                                 \
    [--man]                                                     \
    [--meta]                                                    \
    <inputDir>                                                  \
    <outputDir>

Run

这个plugin可以在两种模式下运行:以python包的形式运行,或者以容器化的docker映像的形式运行。

Using PyPI

要从pypi运行,只需执行a

pip install z2labelmap

并使用

z2labelmap.py --man /tmp /tmp

获取内联帮助。

Using ^{tt1}$

要使用docker运行,请确保将“input”目录分配给/incoming,将输出目录分配给/outgoing确保$(pwd)/out目录是全局可写的!

现在,在所有通话前加上

docker run --rm -v $(pwd)/in:/incoming -v $(pwd)/out:/outgoing      \
        fnndsc/pl-z2labelmap z2labelmap.py                          \

因此,获得内联帮助是:

docker run --rm -v $(pwd)/in:/incoming -v $(pwd)/out:/outgoing      \
        fnndsc/pl-z2labelmap z2labelmap.py                          \
        --man                                                       \
        /incoming /outgoing

Examples

Create a sample/random z-score file and analyze

  • 在没有实际z-score文件的情况下,脚本可以创建一个。这可用于后续分析:
mkdir in out
docker run --rm -v $(pwd)/in:/incoming -v $(pwd)/out:/outgoing  \
        fnndsc/pl-z2labelmap z2labelmap.py                      \
        --random --seed 1                                       \
        --posRange 3.0 --negRange -3.0                          \
        /incoming /outgoing

或不带Docker

mkdir in out
z2labelmap.py                                                   \
        --random --seed 1                                       \
        --posRange 3.0 --negRange -3.0                          \
        /in /out

在本例中,z-scores的范围在0.0到(+/-)3.0之间。

Generate labelmap and also copy pre-calculated image set to output

  • 分析已位于in/zfile.csv的文件并复制预计算的图像数据
docker run --rm -v $(pwd)/in:/incoming -v $(pwd)/out:/outgoing  \
        fnndsc/pl-z2labelmap z2labelmap.py                      \
        --negColor B --posColor R                               \
        --imageSet ../data/set1                                 \
        /incoming /outgoing

这假设在<;inputdirectory>;中有一个名为“z file.csv”的文件,其z-score范围在0.0到3.0之间,并使用–scalerange将地图的视亮度降低50%。此外,较低的80%的z分数被删除(这只会显示最亮的20%的zscore)。

Control relative brightness and lower filter low z-scores from final labelmap

  • 若要分析已位于in/zfile.csv的文件,请应用scaleRange,并过滤掉较低80%的z分数:
docker run --rm -v $(pwd)/in:/incoming -v $(pwd)/out:/outgoing  \
        fnndsc/pl-z2labelmap z2labelmap.py                      \
        --scaleRange 2.0 --lowerFilter 0.8                      \
        --negColor B --posColor R                               \
        /incoming /outgoing

这假设在<;inputdirectory>;中有一个名为“z file.csv”的文件,其z-score范围在0.0到3.0之间,并使用–scalerange将地图的视亮度降低50%。此外,较低的80%的z分数被删除(这只会显示最亮的20%的zscore)。

使用上面引用的z-score文件,结果是:

0       Unknown                         0   0   0   0
11101       lh-G_and_S_frontomargin         0       0       0       0
11102       lh-G_and_S_occipital_inf        0       0       0       0
11103       lh-G_and_S_paracentral          0       0       0       0
11104       lh-G_and_S_subcentral           103     0       0       0
11105       lh-G_and_S_transv_frontopol     0       0       0       0
11106       lh-G_and_S_cingul-Ant           0       0       110     0
11107       lh-G_and_S_cingul-Mid-Ant       0       0       0       0
11108       lh-G_and_S_cingul-Mid-Post      0       0       111     0
                            ...
                            ...
12167       rh-S_postcentral                0       0       0       0
12168       rh-S_precentral-inf-part        0       0       0       0
12169       rh-S_precentral-sup-part        0       0       0       0
12170       rh-S_suborbital                 0       0       110     0
12171       rh-S_subparietal                0       0       103     0
12172       rh-S_temporal_inf               0       0       0       0
12173       rh-S_temporal_sup               119     0       0       0
12174       rh-S_temporal_transverse        0       0       0       0

Command line arguments

<inputDir>
Required argument.
Input directory for plugin.

<outputDir>
Required argument.
Output directory for plugin.

[-v <level>] [--verbosity <level>]
Verbosity level for app. Not used currently.

[--random] [--seed <seed>]
If specified, generate a z-score file based on <posRange> and <negRange>.  In addition, if a further optional <seed> is passed, then initialize the random generator with that seed, otherwise system time is used.

[-p <f_posRange>] [--posRange <f_posRange>]
Positive range for random max deviation generation.

[-n <f_negRange>] [--negRange <f_negRange>]
Negative range for random max deviation generation.

[-P <'RGB'>] [--posColor <'RGB'>]
Some combination of 'R', 'G', B' for positive heat.

[-N  <'RGB'> [--negColor <'RGB'>]
Some combination of 'R', 'G', B' for negative heat.

[--imageSet <imageSetDirectory>]
If specified, will copy the (container) prepopulated image set in <imageSetDirectory> to the output directory.

[-s <f_scaleRange>] [--scaleRange <f_scaleRange>]
Scale range for normalization. This has the effect of controlling the
brightness of the map. For example, if this 1.5 the effect
is increase the apparent range by 50% which darkens all colors values.

[-l <f_lowerFilter>] [--lowerFilter <f_lowerFilter>]
Filter all z-scores below (normalized) <lowerFilter> to 0.0.

[-u <f_upperFilter>] [--upperFilter <f_upperFilter>]
Filter all z-scores above (normalized) <upperFilter> to 0.0.

[-z <zFile>] [--zFile <zFile>]
z-score file to read (relative to input directory). Defaults to 'zfile.csv'.

[--version]
If specified, print version number.

[--man]
If specified, print (this) man page.

[--meta]
If specified, print plugin meta data.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
ArrayList中实体对象上的JAVA泛型   带Redis的爪哇芹菜vs单用Redis   java在设备面向横向时隐藏标题栏/通知栏   java JXTreeTable:如何使用ComponentProvider为一列设置渲染器   java创建异常的成本与记录异常的成本相比   java在方法参数中使用setter传递新对象   java在一个类中的方法与另一个类中的方法交互时遇到问题   java如何迭代2个大小相等的ArrayList   Java getDesktop()。open在Windows中工作,但在Mac中不工作   从tomcat切换到jetty后的java“无法启动嵌入式容器”,Spring引导   java如何使用void方法   java如何在解组时在JAXB的ValidationEventHandler中获取节点值?   如何使用Akka Java API创建不响应的TCP接收器   JavaScriptjQuery在java中将记录上传到数据库时的进度条   如何在重新绘制时在java小程序中显示上一个图像