头发纤维形态分析工具箱
fibermorph的Python项目详细描述
纤维形态
用于头发曲率和横截面图像分析的Python软件包
快速启动
对于那些想立即运行程序的用户,只需在终端中执行这些命令即可。你需要有康达并知道如何使用它。如果您需要这方面的说明,请阅读下面的详细设置。在
- 在
创建conda环境。
在conda create -n fibermorph_env python=3.8
- 在
激活此环境。
在conda activate fibermorph_env
- 在
安装fibermorph。
在pip install fibermorph
- 在
用真实数据测试纤维形态。
fibermorph --demo_real_curv --output_directory /Users/<UserName>/<ExistingPath>/<NewFolderName
以及
在fibermorph --demo_real_section --output_directory /Users/<UserName>/<ExistingPath>/<NewFolderName
- 在
在你自己的纵向或横截面头发图像的灰度tiff上使用fibermorph。在
fibermorph --curvature --input_directory /Users/<UserName>/<ImageFolderPath> --output_directory /Users/<UserName>/<ExistingPath>/ --resolution_mm 132 --jobs 2
以及
在fibermorph --section --input_directory /Users/<UserName>/<ImageFolderPath> --output_directory /Users/<UserName>/<ExistingPath>/ --minsize 30 --maxsize 180 --resolution_mu 4.25 --jobs 2
设置
- 在
我们建议您为您的操作系统下载miniconda。 您也可以下载Anaconda。唯一的区别是Anaconda预装了更多的库(500MB)。你不需要这个来运行fibermorph,所以我们建议你使用minconda,它更小(58mb),下载速度更快。在
无论您选择哪一个,请务必下载带有python3.X而不是python2.X的版本。在
在 - 在
打开终端。在
Mac操作系统:
- 打开Terminal应用程序。在
窗口:
- 在搜索框中键入
miniconda
,然后打开应用程序。在
Linux:
- 打开Terminal应用程序。在
- 在
现在您可以设置一个虚拟环境。在
创建一个空的conda环境,例如
在conda create -n <fibermorph_env python=3.8
并加载它conda activate fibermorph_env
您现在可以安装fibermorph了!在
安装程序包
- 激活新的虚拟环境后,只需运行
pip install fibermorph
。 您可以在这个GitHub页面和fibermorph PyPI page上找到最新版本here。在 - 您已成功安装fibermorph。
这个包现在可以使用了。输入
fibermorph -h
或fibermorph --help
查看所有标志。您可以继续阅读来尝试演示,并阅读软件包中各个模块的说明。在
演示数据
在对您自己的任何数据使用此方法之前,建议您先测试一下fibermorph是否在您的机器上正常工作。有几个demo
模块可以用来检查fibermorph是否正确运行。在
使用真实数据进行测试
您可以使用实际数据测试曲率和截面模块,这些数据是在运行--demo_real
模块时自动下载的。在
在这两种情况下,您只需指定一个文件夹路径,在该路径中可以使用---output_directory
或-o
创建图像和结果。此文件夹可以存在,但也可以通过将其包含在新路径中来建立新文件夹。在
两个模块都会将演示数据下载到您指定路径中的新文件夹tmpdata
。然后,fibermorph将运行曲率或截面分析,结果将保存在同一位置的新文件夹results_cache
。建议您使用新的文件夹名称指定路径,以使所有内容井然有序。在
测试曲率分析
--demo_real_curv
这个标志将用真实数据运行fibermorph曲率分析的演示。您需要为要下载的演示数据提供一个文件夹。在
要运行演示,您将输入以下内容:
fibermorph --demo_real_curv --output_directory /Users/<UserName>/<ExistingPath>/<NewFolderName
测试断面分析
--demo_real_section
此标志将使用实际数据运行fibermorph截面分析的演示。您需要为要下载的演示数据提供一个文件夹。在
要运行演示,您将输入以下内容:
fibermorph --demo_real_section --output_directory /Users/<UserName>/<ExistingPath>/<NewFolderName
曲率
要从头发纤维的灰度TIFF图像计算曲率,除了输入和输出目录外,还将标记--curvature
与以下标志一起使用:
--resolution_mm Integer. Number of pixels per mm for
curvature analysis.
Default is 132.
--window_size [ ...] Float or integer or None. Desired size for
window of measurement
for curvature analysis in pixels or mm (given
the flag --window_unit). If nothing is entered, the default
is None and the entire hair will be used to for the curve fitting."
--window_unit {px,mm} String. Unit of measurement for window of
measurement for curvature
analysis. Can be 'px' (pixels) or 'mm'. Default is 'px'.
-W, --within_element Boolean. Default is False. Will create
an additional directory with
spreadsheets of raw curvature measurements for each hair if the
--within_element flag is included.
-s, --save_image Default is False. Will save intermediate
curvature/section processing images if
--save_image flag is included.
所以,进行曲率分析是,您可以输入例如
^{pr2}$截面
要从头发纤维的灰度TIFF图像计算横截面属性,请使用标记--section
和以下标志:
--resolution_mu Float. Number of pixels per micron for section analysis. Default is 4.25.
--minsize Integer. Minimum diameter in microns for sections. Default is 20.
--maxsize Integer. Maximum diameter in microns for sections. Default is 150.
一个示例命令是:
fibermorph --section --input_directory /Users/<UserName>/<ImageFolderPath> --output_directory /Users/<UserName>/<ExistingPath>/ --minsize 20 --maxsize 150 --resolution_mu 4.25 --jobs 2
将原始图像转换为灰度TIFF
此软件包提供了一个附加的辅助模块,用于在必要时将原始图像转换为灰度TIFF文件:--raw2gray
除了输入和输出目录外,模块还需要用户指定它应该查找的文件扩展名。在
--file_extension Optional. String. Extension of input files to use in input_directory when
using raw2gray function. Default is .RW2.
用户可以输入,例如:
fibermorph --raw2gray --input_directory /Users/<UserName>/<ImageFolderPath> --output_directory /Users/<UserName>/<ExistingPath>/<NewFolderName> --file_extension .RW2 --jobs 4
- 项目
标签: