正则表达式路径匹配器 - 轻松批量操作文件夹和文件树!
项目描述
Pathmatcher:使用强大的正则表达式像操作简单文本一样操作文件路径树!
Pathmatcher是一个Python中的文件和文件夹层次结构管理工具,它对路径进行正则表达式匹配(而不仅仅是文件名)。它可以显示模拟报告并自动检测冲突(已存在的文件、由于正则表达式导致多个文件复制到相同的输出文件名等)。也可以用作Python模块,返回匹配的文件和转换列表。
如果你经常运行实验,使用脚本和应用程序,其中一些不是你自己设计的。那么这些应用程序/脚本可能期望特定的目录结构才能工作。通常,你需要手动重新组织你的文件。这不仅耗时,而且容易出错(例如,将错误的文件复制到错误的位置)。
如果你遇到这种情况,这个工具可能对你有帮助:只需指定一个匹配所需文件的正则表达式,输入一个输出正则表达式(可以重用输入文件的某些部分,例如你的受试者ID,使用正则表达式组和回忆),然后启动程序。
此模块适用于任何文件管理目的,尽管它最初是为了处理神经影像学预处理任务而创建的,例如将任何数据集快速重新组织成BIDS兼容格式。它还可以与捆绑的reorientation_registration_helper
命令结合使用,展示了如何将此模块与MATLAB和SPM结合以半自动地进行手动脑图像的AC-PC平面解剖重定向。
此应用程序也可以用作Python模块,因此您可以将它包含在管道中,以(半)自动化重复性任务,例如在您喜欢的工具(如SPM)中打开适当的文件。作为Python模块,它不仅可以匹配输入路径,还可以根据命名的正则表达式组动态地将它们分组到树状结构(递归字典)中。这是一个非常有用且强大的工具,可以快速匹配多模态数据并将它们分组在一起(例如,结构和功能图像),每个受试者和每个研究在单个命令中。请参阅reorient_registration_helper.py
以获取示例用法。
在Python 3(已测试Python 3.12)上运行。之前的版本适用于Python 2.7.15,但由于Python 2支持现已弃用,因此不再保证兼容性(但您仍然可以使用旧版本,以下提供说明)。
如果您不熟悉正则表达式,您可以使用在线工具,如Pythex来即时测试您的正则表达式,以及这个简单教程来了解它是如何工作的。
安装
对于Python 3.7+
pip install --upgrade pathmatcher --use-pep517
或者在Windows上,您可以使用GitHub发布版中的预构建二进制文件。
对于最新开发版本,使用
pip install --upgrade pathmatcher --pre --use-pep517
对于最前沿的代码(可能不稳定,不建议在生产中使用!),使用
pip install --upgrade git+https://github.com/lrq3000/pathmatcher --pre --use-pep517
对于Python 2.7到3.6,最后一个兼容版本是v1.7.6
pip install --upgrade pathmatcher==1.7.6
这将为您环境安装两个命令:pathmatcher
和reorientation_registration_helper
。
维护状态
请注意,pyInstaller自包含二进制文件和Gooey GUI不再维护,维护的是命令行界面和Python模块导入。
快速入门
本节通过一个实际操作的介绍来展示pathmatching典型会话的步骤,从如何快速编写一个匹配您文件的正则表达式(regexp)到如何应用它以实现您的目标文件结构。
假设您有一个名为“root”的目录,其中包含子目录,并且在每个子目录中都有一些文件。现在,您想重新组织,使所有文件都在一个单独的文件夹中,但您想保留原始子目录名,并在文件名前添加它。以下是这种文件结构的示意图
root
|--- folderA
|--- file1.txt
|--- file2.txt
|--- file3.txt
|--- folderB
|--- file4.txt
|--- file5.txt
|--- file6.txt
您可以这样匹配它们
pathmatcher -i "root" -ri "(\dir)/(.*)" --test
参数如下
-i
是递归文件搜索的起始输入根目录。-ri
是输入路径的正则表达式,用于匹配您想要的文件。默认情况下,匹配是部分匹配,因此您只需输入要匹配的文件路径的一部分(如果您想使正则表达式匹配整个路径,请使用以^
开头并以$
结尾的正则表达式,例如"^my/whole/path.ext$"
)。(.*)
将匹配任何内容,而\dir
是一个特殊参数,将匹配任何目录(或文件)直到下一个子目录级别,这类似于在树中虚拟地遍历。所有路径都使用/
指定,而不是\
,无论平台如何(包括在 Windows 操作系统上)。在这里,(\dir)
将匹配folderA
和folderB
。如果我们有无限深的子目录数量并且想要递归,我们可以使用(\dir/)+
,这意味着我们匹配:\dir
一个目录,/
一个路径分隔符到下一级(这样我们可以连接多个深度),+
至少一个子目录级别,如果有多个级别,则可以匹配任意多个。--test
将测试是否至少有一个文件可以匹配,然后停止。这对于快速测试正则表达式是否充分匹配您想要的项非常有用,而无需遍历所有文件。
以下是我们的输出
== Regex Path Matcher started ==
Parameters:
- Input root: root
- Input regex: ([^\\/]*?)/(.*)
- Output root: None
- Output regex: None
- Full arguments: X:\Path\To\pathmatcher -i root -ri (\dir)/(.*) --test
Computing paths matching and simulation report, please wait (total time depends on files count - filesize has no influence). Press CTRL+C to abort
Match: folderA/file1.txt
0files [00:00, ?files/s]
End of simulation. 1 files matched.
由于我们匹配了一个文件,这表明正则表达式工作正常,我们可以继续。
注意:如果不起作用(没有文件匹配),并且文件很多,您可以通过按 CTRL+C 提前停止文件搜索。
接下来,输入以下内容
pathmatcher -i "root" -ri "(\dir)/(.*)" -o "out" -ro "\1_\2" --copy
这将重用先前命令的输入参数(除了 --test
)并添加以下 3 个参数
--copy
将将匹配的文件复制到输出文件夹,如果指定了-ro
,则可能修改文件名。其他命令是:--move
、--move_fast
、--delete
、--symlink
。-o
是输出目录。-ro
是输出路径的正则表达式。这允许通过重用匹配输入路径的正则表达式组来动态更改输出文件名。在这里,我们重用捕获在\1
中的子目录名称,并将其重用于在原始输入路径\2
之前添加。
在应用任何文件修改操作之前,pathmatcher 将提供有关其计划执行的操作的完整模拟报告,包括是否存在覆盖冲突(例如,两个不同的文件将获得相同的文件名)。
以下是上面命令的模拟报告
== REGEX PATH MATCHER SIMULATION REPORT ==
Total number of files matched: 6
Parameters:
- Input root: b'root'
- Input regex: ([^\\/]*?)/(.*)
- Output root: b'out'
- Output regex: \1_\2
- Full arguments: X:\Path\To\pathmatcher -i root -ri (\dir)/(.*) -o out -ro \1_\2 --copy
List of matched files:
* folderA/file1.txt --> folderA_file1.txt
* folderA/file2.txt --> folderA_file2.txt
* folderA/file3.txt --> folderA_file3.txt
* folderB/file4.txt --> folderB_file4.txt
* folderB/file5.txt --> folderB_file5.txt
* folderB/file6.txt --> folderB_file6.txt
默认情况下,模拟报告以 pathmatcher_report.txt
的形式保存在当前终端文件夹中(如 pwd
所示),并在默认文本编辑器中打开。此行为可以使用 `--noreport` 修改,这将直接在终端中打印模拟报告。
现在,我们手动审查模拟报告,我们可以看到一切按计划进行。
让我们回到终端
== Regex Path Matcher started ==
Parameters:
- Input root: root
- Input regex: ([^\\/]*?)/(.*)
- Output root: out
- Output regex: \1_\2
- Full arguments: X:\Path\To\pathmatcher -i root -ri (\dir)/(.*) -o out -ro \1_\2 --copy
Computing paths matching and simulation report, please wait (total time depends on files count - filesize has no influence). Press CTRL+C to abort
12files [00:00, ?files/s]
End of simulation. 6 files matched.
Preparing simulation report, please wait a few seconds...
Opening simulation report with your default editor, a new window should open.
No conflict detected. You are good to go!
Do you want to apply the result of the path reorganization simulation on 6 files? [Y/N]:
终端确认没有冲突(这也会在模拟报告中出现),并询问我们是否要继续。
如果我们输入 Y
并按 Enter,则根据上述模拟报告复制和重命名文件。如果我们输入 N
或简单地按 CTRL+C,则应用程序停止。
本快速入门教程到此结束。您可以使用这个工具做很多事情,比如匹配精确的数字范围(比如您有1到100编号的图片,您想删除前3个,可以使用-ra 4:1-3 --delete
命令,其中4
是输入正则表达式匹配组的位序,该组匹配输入路径中的数字)。默认情况下,只有指向文件的路径被视为叶子节点并执行遍历,目录被视为节点(这是为了避免多次处理相同的目录导致的各种路径 - 对于文件,我们确信它是一个叶子节点,在理论上,树中有一个唯一的路径指向它),但您可以使用--dir
将任何目录视为叶子节点(在这种情况下,遍历顺序如下:首先文件,然后最深层的子目录,然后逐步向上到根目录,并按字母顺序,所以遍历顺序始终是确定的)。
还有非常强大的--tree
选项,也可以作为Python模块使用时的参数,它允许将匹配的输入文件以树状结构分组,这是一种匹配多模态数据并将它们聚类在一起的有效方法,通常只需要一个命令,然后使用您的脚本进行后处理。
提示:如果您无法使用单个命令完成文件重组任务,尝试将任务分解为几个更小的步骤,例如,首先重命名,然后移动,然后再次重命名,然后再次移动,然后删除不必要的文件等。通常,看似不可能的文件重组任务可以用几个较小的pathmatcher
调用轻松完成。
用法
命令行
Pathmatcher安装了两个控制台二进制文件,您可以直接从命令行调用。
usage: pathmatcher [-h] -i /some/path -ri "sub[^/]+/\d+" [-o /new/path] [-ro "newsub/\1"] [-c] [-s] [-m]
[--move_fast] [-d] [-t] [--dir] [-y] [-f] [--show_fullpath] [-ra 1:10-255]
[-re "newsub/\1"] [--report pathmatcher_report.txt] [--noreport] [--tree]
[-l /some/folder/filename.log] [-v] [--silent]
Regex PathMatcher v1.7.4
Description: Match paths using regular expression, and then generate a report. Can also substitute using regex to generate output paths. A copy mode is also provided to allow the copy of files from input to output paths.
This app is essentially a path matcher using regexp, and it then rewrites the path using regexp, so that you can reuse elements from input path to build the output path.
This is very useful to reorganize folders for experiments, where scripts/softwares expect a specific directories layout in order to work.
Advices
-------
- Filepath comparison: Paths are compared against filepaths, not just folders (but of course you can match folders with regex, but remember when designing your regexp that it will compared against files paths, not directories).
- Relative filepath: Paths are relative to the rootpath (except if --show-fullpath) and that they are always unix style, even on Windows (for consistency on all platforms and to easily reuse regexp).
- Partial matching: partial matching regex is accepted, so you don't need to model the full filepath, only the part you need (eg, 'myfile' will match '/myfolder/sub/myfile-034.mat').
- Unix filepaths: on all platforms, including Windows, paths will be in unix format (except if you set --show_fullpath). It makes things simpler for you to make crossplatform regex patterns.
- Use [^/]+ to match any file/folder in the filepath: because paths are always unix-like, you can use [^/]+ to match any part of the filepath. Eg, "([^/]+)/([^/]+)/data/mprage/.+\.(img|hdr|txt)" will match "UWS/John_Doe/data/mprage/12345_t1_mprage_98782.hdr".
- Split your big task in several smaller, simpler subtasks: instead of trying to do a regex that match T1, T2, DTI, everything at the same time, try to focus on only one modality at a time and execute them using multiple regex queries: eg, move first structural images, then functional images, then dti, etc. instead of all at once.
- Python module: this library can be used as a Python module to include in your scripts (just call `main(return_report=True)`).
Note: use --gui (without any other argument) to launch the experimental gui (needs Gooey library).
In addition to the switches provided below, using this program as a Python module also provides 2 additional options:
- return_report = True to return as a variable the files matched and the report instead of saving in a file.
- regroup = True will return the matched files (if return_report=True) in a tree structure of nested list/dicts depending on if the groups are named or not. Groups can also avoid being matched by using non-matching groups in regex.
optional arguments:
-h, --help show this help message and exit
-i /some/path, --input /some/path
Path to the input folder
-ri "sub[^/]+/(\d+)", --regex_input "sub[^/]+/(\d+)"
Regex to match input paths. Must be defined relatively from --input folder. Do not forget to enclose it in double quotes (and not single)! To match any directory, use [^/\]*? or the alias \dir, or \dirnodot if you want to match folders in combination with --dir switch.
-o /new/path, --output /new/path
Path to the output folder (where file will get copied over if --copy)
-ro "newsub/\1", --regex_output "newsub/\1"
Regex to substitute input paths to convert to output paths. Must be defined relatively from --output folder. If not provided but --output is specified, will keep the same directory layout as input (useful to extract specific files without changing layout). Do not forget to enclose it in double quotes!
-c, --copy Copy the matched input paths to the regex-substituted output paths.
-s, --symlink Copy with a symbolic/soft link the matched input paths to the regex-substituted output paths (works only on Linux).
-m, --move Move the matched input paths to the regex-substituted output paths.
--move_fast Move the matched input paths to the regex-substituted output paths, without checking first that the copy was done correctly.
-d, --delete Delete the matched files.
-t, --test Regex test mode: Stop after the first matched file and show the result of substitution. Useful to quickly check if the regex patterns are ok.
--dir Match directories too? (else only files are matched)
-y, --yes Automatically accept the simulation and apply changes (good for batch processing and command chaining).
-f, --force Force overwriting the target path already exists. Note that by default, if a file already exist, without this option, it won't get overwritten and no message will be displayed.
--show_fullpath Show full paths instead of relative paths in the simulation.
-ra 1:10-255, --range 1:10-255
Range mode: match only the files with filenames containing numbers in the specified range. The format is: (regex-match-group-id):(range-start)-(range-end). regex-match-group-id is the id of the regular expression that will contain the numbers that must be compared to the range. range-end is inclusive.
-re "newsub/\1", --regex_exists "newsub/\1"
Regex of output path to check if the matched regex here is matched prior writing output files.
--report pathmatcher_report.txt
Where to store the simulation report (default: pwd = current working dir).
--noreport Do not create a report file, print the report in the console.
--tree Regroup in a tree structure the matched files according to named and unnamed regex groups, and save the result as a json file (pathmatcher_tree.json).
-l /some/folder/filename.log, --log /some/folder/filename.log
Path to the log file. (Output will be piped to both the stdout and the log file)
-v, --verbose Verbose mode (show more output).
--silent No console output (but if --log specified, the log will still be saved in the specified file).
作为Python模块
要从Python脚本中使用pathmatcher,请使用以下命令
>>> from pathmatcher import pathmatcher
然后您可以调用pathmatcher()
。
库
注意:所有依赖项都应通过pyproject.toml标准使用pip install
安装。
必需
- 核心Python库...
- argparse
- pathlib2(由脚本提供)
- Tee(由脚本提供)
可选
- tqdm(用于进度条,强烈推荐)
- scandir(用于更快的文件遍历和模拟报告)
- Gooey(用于GUI - 可能不再维护,截至2024年可能不再工作)
教程
以下是pathmatcher
使用简介。
您应该记住的最重要技巧是:尽量将操作拆分到多个命令中。确实,首先匹配解剖学,然后是功能性,然后是dwi等,比尝试在单个命令中匹配和重新排序它们(虽然可能但很难,以获得完全相同的结果!)要简单。
让我们举一个具体的例子:我们将把来自ABIDE I数据集的NIfTI文件重新组织到BIDS方案。
为此,首先在您想要的位置创建一个目录(我们将称此目录为“根目录”,并将所有ABIDE I数据集解压缩到一个名为“ABIDE”的文件夹中)。然后,在根目录内,在“ABIDE”文件夹旁边创建另一个文件夹ABIDE-BIDS
。现在,打开终端/控制台,并将cd
切换到根目录,其中现在有两个子目录:“ABIDE”包含ABIDE1数据,以及空的ABIDE-BIDS
。
现在,在命令行中执行以下两个命令
pathmatcher -ri "Caltech_([0-9]+)/\dir/scans/anat/resources/NIfTI/files/mprage.nii.gz" -ro "sub-\1/anat/sub-\1_T1w.nii.gz" -i ABIDE/ -o ABIDE-BIDS/ -c
pathmatcher -ri "Caltech_([0-9]+)/\dir/scans/rest/resources/NIfTI/files/rest.nii.gz" -ro "sub-\1/func/sub-\1_task-rest_bold.nii.gz" -i ABIDE/ -o ABIDE-BIDS/ -c
其中 -i = --input
(基本输入目录),-o = --output
(基本输出目录,文件将复制/移动到该目录),-ri = --regex_input
(匹配输入文件的正则表达式),-ro = --regex_output
(将输入文件复制/移动到输出文件夹的正则表达式),-c = --copy
(启用复制模式,也可以选择 --symlink, --move, --delete)。注意,您可以输入 --help
来获取关于参数的详细文档和建议。
另外,\dir
是 [^/\]*
的别名,允许可靠地匹配路径中的任何目录。注意,--regex_input
(-ri
)和--regex_output
(-ro
)是相对于 --input
和 --output
目录的路径匹配,因此路径匹配器中不存在 --input
和 --output
以上的路径。这样做有两个原因:使您更容易编写正则表达式(因为您不需要考虑 --input
或 --output
中的任何父文件夹),并且出于安全考虑(避免在您的磁盘根目录上执行 --delete
!您有保证,路径匹配器仅在子目录上工作)。
执行这两个命令后,pathmatcher
将生成一个报告,详细说明它将执行的所有文件操作,并最终警告您关于冲突(具有相同文件名的文件在输出文件夹中发生冲突)。
这可以很好地将 ABIDE I
数据集方案转换为 BIDS
,但这可以简化。Pathmatcher 是为了允许宽松匹配而制作的,所以基本想法是您应该只尝试匹配您需要的东西(要么是为了在输出中重新捕获使用,如受试者 ID,要么是为了消除歧义,如文件夹名称)。以下有两个简化的命令,它们执行与上面相同的功能
pathmatcher -c -i "ABIDE/" -o "ABIDE-BIDS/" -ri "Caltech_([0-9]+)/.+/mprage.nii.gz" -ro "sub-\1/anat/sub-\1_T1w.nii.gz"
pathmatcher -c -i "ABIDE/" -o "ABIDE-BIDS/" -ri "Caltech_([0-9]+)/.+/rest.nii.gz" -ro "sub-\1/func/sub-\1_task-rest_bold.nii.gz"
也支持部分匹配,因此如果您只想获取所有 T1 的列表,您可以执行以下操作
pathmatcher -i "ABIDE/" -ri "mprage.nii.gz"
这将生成整个 T1 列表,并在报告中显示它们。
当然,您也可以为 --input
和 --output
使用绝对路径。
还有一个技巧可以帮助您设计正则表达式:使用 --test
参数来查看它是否至少匹配一个文件,以及将执行什么操作
pathmatcher -c --test -i "ABIDE/" -o "ABIDE-BIDS/" -ri "Caltech_([0-9]+)/.+/mprage.nii.gz" -ro "sub-\1/anat/sub-\1_T1w.nii.gz"
结果
== Regex Path Matcher started ==
Parameters:
- Input root: C:\GigaData\BIDS\ABIDE
- Input regex: Caltech_([0-9]+)/.+/mprage.nii.gz
- Output root: C:\GigaData\BIDS\ABIDE-BIDS
- Output regex: sub-\1/anat/sub-\1_T1w.nii.gz
Computing paths matching and simulation report, please wait (total time depends
on files count - filesize has no influence). Press CTRL+C to abort
Match: Caltech_51456/Caltech_51456/scans/anat/resources/NIfTI/files/mprage.nii.gz --> sub-51456/anat/sub-51456_T1w.nii.gz
End of simulation. 1 files matched.
最后,pathmatcher
可以作为您自己脚本的组成部分使用,要么通过在命令行上使用带有 --yes
参数的 pathmatcher
来跳过报告,要么通过在您的 Python 脚本中使用以下内容
from pathmatcher import main as pm
# Match all T1 from ABIDE I, don't forget the r'' to avoid conflicts with / character
# You can use the commandline arguments, but the script will be called without bash but directly inside Python
my_results = pm(r'-i "ABIDE/" -ri "mprage.nii.gz"', return_report=True) # use return_report=True to get the matches returned to your my_results variable
print(my_results)
可以在 reorientation_registration_helper
伴随脚本中找到 pathmatcher
的具体示例脚本,该脚本简化了 fMRI 数据的手动预处理(重新定向、配准、质量检查和运动评估、生成复合运动度量,如帧间中值绝对偏差等)。
类似项目
一个类似的项目,也许更强大的是 fselect,它允许对文件使用类似 SQL 的查询。在 MATLAB 中,类似的功能在 dirPlus 中可用。
辅助工具:重新定向和配准助手
描述
这是一个辅助脚本,帮助您在 SPM 中手动重新定向和配准结构和功能 MRI,无需点击选择文件。
此辅助脚本将扫描指定输入路径中的所有图像,并逐步引导您正确地进行重新定向和配准。
此脚本需要 SPM12(和 MATLAB),并且仅在 Windows 上运行(由于 MATLAB 包装器的限制)。
此脚本遵循以下步骤
- 使用 spm_auto_reorient.m 自动重新定向结构 MRI(请事先安装此脚本和 SPM12)。
- 手动检查重新定向并调整。
- 对照多个受试者的结构 MRI 进行并列检查。
- 检测功能图像(只需遍历所有文件夹以构建功能图像列表,并根据输入正则表达式将它们与其相应的结构图像配对)。
- 自动将功能图像配准到结构图像上。
- 功能图像与结构图像的手动配准。
- 从功能图像中提取帧间位移运动度量。
此脚本不仅会按照正确顺序引导您完成这些步骤,还会自动为您加载文件(不会出错或遗漏受试者),同时显示进度条(显示剩余受试者数量和完成时间估计)。
有一个命令行界面:您可以跳过已完成的步骤或不想做的步骤,跳过患者,或重新加载另一张图像(第4步,检查其他功能图像)。
请注意,最后一步,从功能图像中提取帧间位移运动度量,无需matlab或matlab包装器(因此应该在任何平台上都能工作),可以使用--motiononly
和--regex_motion
开关(这将直接查找您之前使用spm_realign
生成的rp_*.txt
文件)。
依赖项
要使用此辅助工具,您需要先安装pip install numpy
。
用法
命令行
usage: reorientation_registration_helper [-h] -i /some/path [-ra "reg_expr+/anat\.(img|nii)"]
[-rf "reg_expr+/func\.(img|nii)"] [-rp "reg_expr+/rp_.+\.txt"] [-m]
[-v]
Reorientation and registration helper v1.7.4
Description: Guide and automate the file selection process that is required in SPM between each reorientation/registration.
No more useless clicks, just do the reorientation/registration in batch, you don't need to worry about selecting the corresponding files, this helper will do it for you.
If you have tqdm installed, a nice progress bar will tell you how many subjects are remaining to be processed and how much time will it take at your current pace.
Note: you need to `pip install mlab` before using this script.
Note2: you need to have set both spm and spm_auto_reorient in your path in MATLAB before using this script.
Note3: you need the pathmatcher.py library (see lrq3000 github).
optional arguments:
-h, --help show this help message and exit
-i /some/path, --input /some/path
Path to the input folder (the root directory where you placed the files, the default supported tree structure being: "Condition/subject_id/data/(sess_id)?/(mprage|rest)/*.(img|nii)". You can also use --regex_anat and --regex_func to define your own directory layout.
-ra "(reg_expr)+/anat\.(img|nii)", --regex_anat "(reg_expr)+/anat\.(img|nii)"
Regular expression to match anatomical images (default: Liege CRC scheme). Use regex groups to match with functional regex (if you want to do step 4 - manual coreg). Note: should target nii or img, not hdr.
-rf "(reg_expr)+/func\.(img|nii)", --regex_func "(reg_expr)+/func\.(img|nii)"
Regular expression to match functional images (default: Liege CRC scheme). Regex groups will be matched with the anatomical regex, so you should provide the same groups for both regex. Note: should target nii or img, not hdr (using non-capturing group, eg: ".*\.(?:img|nii)". If a named group (?P<func>...) is specified, this will allow to separately coregister any file matching this group, which will be removed from the list of regex groups (thus this group is additional, it does not count in the "same number of groups" rule).
-rp "(reg_expr)+/rp_.+\.txt", --regex_motion "(reg_expr)+/rp_.+\.txt"
Regular expression to match motion parameter files rp_*.txt as generated by spm_realign. If this argument is provided, motion parameters will be fetched from these files directly instead of recalculating from functional images. The regex needs to contain at least one group in parentheses to define a key for the output excel file.
-m, --motiononly If true, and if --regex_motion is specified, then only this step will be done, using the already generated rpfiles.
-v, --verbose Verbose mode (show more output).
作为Python模块
要从Python脚本中使用此辅助工具,请使用以下命令
>>> from pathmatcher.reorientation_registration_helper import main as reorientation_registration_helper
然后您可以调用reorientation_registration_helper()
。
库
必需
- numpy >= 1.18.1,用于从功能图像生成运动度量(默认情况下不作为依赖项安装,以保持主工具路径匹配器的依赖项最小,请提前安装)
- argparse
- pathmatcher
- mlabwrap即matlap_wrapper(Python2版本,Python3版本,作为此模块提供)
- pypiwin32(用于mlabwrap)
- pip install --ignore-installed pywin32
- 然后在管理员命令提示符中执行
python Scripts\pywin32_postinstall.py -install
,参见此说明。
- 然后在管理员命令提示符中执行
可选
- scandir,用于更快地扫描文件
- tqdm,用于显示进度条
项目详细信息
下载文件
下载您平台上的文件。如果您不确定选择哪个,请了解更多关于安装软件包的信息。