头发纤维形态分析工具箱

fibermorph的Python项目详细描述


纤维形态

用于头发曲率和横截面图像分析的Python软件包

快速启动

对于那些想立即运行程序的用户,只需在终端中执行这些命令即可。你需要有康达并知道如何使用它。如果您需要这方面的说明,请阅读下面的详细设置。在

  1. 创建conda环境。 conda create -n fibermorph_env python=3.8

  2. 激活此环境。 conda activate fibermorph_env

  3. 安装fibermorph。 pip install fibermorph

  4. 用真实数据测试纤维形态。
    fibermorph --demo_real_curv --output_directory /Users/<UserName>/<ExistingPath>/<NewFolderName

    以及

    fibermorph --demo_real_section --output_directory /Users/<UserName>/<ExistingPath>/<NewFolderName

  5. 在你自己的纵向或横截面头发图像的灰度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

设置

  1. 我们建议您为您的操作系统下载miniconda。 您也可以下载Anaconda。唯一的区别是Anaconda预装了更多的库(500MB)。你不需要这个来运行fibermorph,所以我们建议你使用minconda,它更小(58mb),下载速度更快。在

    无论您选择哪一个,请务必下载带有python3.X而不是python2.X的版本。在

  2. 打开终端。在

    Mac操作系统:

    • 打开Terminal应用程序。在

    窗口:

    • 在搜索框中键入miniconda,然后打开应用程序。在

    Linux:

    • 打开Terminal应用程序。在
  3. 现在您可以设置一个虚拟环境。在

    创建一个空的conda环境,例如conda create -n <fibermorph_env python=3.8并加载它conda activate fibermorph_env 您现在可以安装fibermorph了!在

安装程序包

  1. 激活新的虚拟环境后,只需运行pip install fibermorph。 您可以在这个GitHub页面和fibermorph PyPI page上找到最新版本here。在
  2. 您已成功安装fibermorph。 这个包现在可以使用了。输入fibermorph -hfibermorph --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

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

推荐PyPI第三方库


热门话题
java不兼容类型:MainActivity无法转换为LifecycleOwner   java安卓是一种更有效的读取大文本文件的方法   java导出LWJGL本地人与项目?(IntelliJ IDEA)   JDK更新后,JavaJShell不再在下一行打印输出   父类对象上的继承Java比较子属性   Java:有没有一个容器可以有效地结合HashMap和ArrayList?   安卓 Java对象指针   java在annotationdriven Spring MVC应用程序中实现大气   java 安卓源代码构建应用找不到安卓supportv4。罐子   文件系统上的抽象层和Java中的jar/zip   java在水平滚动视图中添加多个图像?   java如何从firebase实时数据库中获取字符串数组   WIndows 10工作站上的java未满足链接错误   java命令在终端中工作,但在使用过程中出现“无结束引号”错误。执行官