用于分析PF*系列中的DICOM文件的基本模块。
pfdicom的Python项目详细描述
目录
Quick Overview
- pfdicom主要是其他更专门的类的基模块。它通常从不单独使用。
Overview
pfdicom本身提供最小的结束值。此模块/类旨在成为更深层功能的构建块。它的目的是探测给定目录文件系统中的dicom文件并构造一个树表示(使用pftree),然后,为每个目录提供读取给定dicom文件(使用pydicom)的方法,以提供一些最小的标记提取和输出文件模板。
最重要的是,这个父类的派生类可以提供详细而强大的方法来处理包含dicom文件的目录,并将结果保存到输出文件树中。例如,在这个机箱上构建了各种模块,包括pfdicom_tagExtract和pfdicom_tagSub。
Installation
Dependencies
以下依赖项安装在主机系统/python3 virtual env上(如果从pypi中提取,它们也将自动安装):
- pfmisc(pf*对象系列的各种杂项模块和类)
- pftree(创建文件系统层次结构的字典表示)
Command line arguments
-I|--inputDir <inputDir> Input DICOM directory to examine. By default, the first file in this directory is examined for its tag information. There is an implicit assumption that each <inputDir> contains a single DICOM series. [--maxdepth <dirDepth>] The maximum depth to descend relative to the <inputDir>. Note, that this counts from zero! Default of '-1' implies transverse the entire directory tree. -i|--inputFile <inputFile> An optional <inputFile> specified relative to the <inputDir>. If specified, then do not perform a directory walk, but convert only this file. [-O|--outputDir <outputDir>] The directory to contain all output files. [-O|--outputDir <outputDir>] The directory to contain all output files. [--outputLeafDir <outputLeafDirFormat>] If specified, will apply the <outputLeafDirFormat> to the output directories containing data. This is useful to blanket describe final output directories with some descriptive text, such as 'anon' or 'preview'. This is a formatting spec, so --outputLeafDir 'preview-%s' where %s is the original leaf directory node, will prefix each final directory containing output with the text 'preview-' which can be useful in describing some features of the output set. -e|--extension <DICOMextension> An optional extension to filter the DICOM files of interest from the <inputDir>. [-t|--threads <numThreads>] If specified, break the innermost analysis loop into <numThreads> threads. Please note the following caveats: * Only thread if you have a high CPU analysis loop. Since most of the operations of this module will entail reading and writing DICOM files, and since these operations are the bulk of the execution time, adding threading will not really help. * Threading will change the nature of the innermost looping across the problem domain, with the result that *all* of the problem data will be read into memory! That means all of DICOMs across all of the subdirs! In non-threading mode, only DICOMs from a single directory at a time are read and then discarded. This flag is less applicable to this base class. It is here to provide fall-through compatibility with derived classes. [-x|--man] Show full help. [-y|--synopsis] Show brief help. [--json] If true, dump the final return as JSON formatted string. [--followLinks] If specified, follow symbolic links. [--version] If specified, print a version string. -v|--verbosity <level> Set the app verbosity level. 0: No internal output; 1: Most important internal output -- none for 'pfdicom'; 2: As with level '1' but with simpleProgress bar in 'pftree'; 3: As with level '2' but with list of input dirs/files in 'pftree';
String processing on tag values
pfidcom提供了一些关于标记值的函数,这些函数通常是基于字符串的。语法为:
%_<functionName>|<arg>_<tagName>
例如,
%_md5|7_PatientID
已确定PatientID的md5哈希。在结果字符串中,使用前7个字符。这将作为PatientID标记的值返回。
%_strmsk|******01_PatientBirthDate
PatientBirthDate值被屏蔽,因此前六个字符被保存,但最后两个字符被“01”替换。这会将PatientBirthDate设置为出生月份的第一天。
%_nospc|-_ProtocolName
处理ProtocolName以删除所有空白,并使用“-”字符而不是任何空白组件。
Examples
在目标树上运行,创建特定文件和目录结构的内部表示。
pfdicom -I /var/www/html \ -O /tmp \ -o %PatientID-%PatientAge \ -e .dcm \ -v 0 --json which will output only at script conclusion and will log a JSON formatted string.