rapidtide 3.0.10__py3-none-any.whl → 3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rapidtide/Colortables.py +492 -27
- rapidtide/OrthoImageItem.py +1053 -47
- rapidtide/RapidtideDataset.py +1533 -86
- rapidtide/_version.py +3 -3
- rapidtide/calccoherence.py +196 -29
- rapidtide/calcnullsimfunc.py +191 -40
- rapidtide/calcsimfunc.py +245 -42
- rapidtide/correlate.py +1210 -393
- rapidtide/data/examples/src/testLD +56 -0
- rapidtide/data/examples/src/testalign +1 -1
- rapidtide/data/examples/src/testdelayvar +0 -1
- rapidtide/data/examples/src/testfmri +19 -1
- rapidtide/data/examples/src/testglmfilt +5 -5
- rapidtide/data/examples/src/testhappy +30 -1
- rapidtide/data/examples/src/testppgproc +17 -0
- rapidtide/data/examples/src/testrolloff +11 -0
- rapidtide/data/models/model_cnn_pytorch/best_model.pth +0 -0
- rapidtide/data/models/model_cnn_pytorch/loss.png +0 -0
- rapidtide/data/models/model_cnn_pytorch/loss.txt +1 -0
- rapidtide/data/models/model_cnn_pytorch/model.pth +0 -0
- rapidtide/data/models/model_cnn_pytorch/model_meta.json +68 -0
- rapidtide/data/reference/JHU-ArterialTerritoriesNoVent-LVL1_space-MNI152NLin2009cAsym_2mm.nii.gz +0 -0
- rapidtide/data/reference/JHU-ArterialTerritoriesNoVent-LVL1_space-MNI152NLin2009cAsym_2mm_mask.nii.gz +0 -0
- rapidtide/decorators.py +91 -0
- rapidtide/dlfilter.py +2225 -108
- rapidtide/dlfiltertorch.py +4843 -0
- rapidtide/externaltools.py +327 -12
- rapidtide/fMRIData_class.py +79 -40
- rapidtide/filter.py +1899 -810
- rapidtide/fit.py +2004 -574
- rapidtide/genericmultiproc.py +93 -18
- rapidtide/happy_supportfuncs.py +2044 -171
- rapidtide/helper_classes.py +584 -43
- rapidtide/io.py +2363 -370
- rapidtide/linfitfiltpass.py +341 -75
- rapidtide/makelaggedtcs.py +211 -20
- rapidtide/maskutil.py +423 -53
- rapidtide/miscmath.py +827 -121
- rapidtide/multiproc.py +210 -22
- rapidtide/patchmatch.py +234 -33
- rapidtide/peakeval.py +32 -30
- rapidtide/ppgproc.py +2203 -0
- rapidtide/qualitycheck.py +352 -39
- rapidtide/refinedelay.py +422 -57
- rapidtide/refineregressor.py +498 -184
- rapidtide/resample.py +671 -185
- rapidtide/scripts/applyppgproc.py +28 -0
- rapidtide/simFuncClasses.py +1052 -77
- rapidtide/simfuncfit.py +260 -46
- rapidtide/stats.py +540 -238
- rapidtide/tests/happycomp +9 -0
- rapidtide/tests/test_dlfiltertorch.py +627 -0
- rapidtide/tests/test_findmaxlag.py +24 -8
- rapidtide/tests/test_fullrunhappy_v1.py +0 -2
- rapidtide/tests/test_fullrunhappy_v2.py +0 -2
- rapidtide/tests/test_fullrunhappy_v3.py +1 -0
- rapidtide/tests/test_fullrunhappy_v4.py +2 -2
- rapidtide/tests/test_fullrunrapidtide_v7.py +1 -1
- rapidtide/tests/test_simroundtrip.py +8 -8
- rapidtide/tests/utils.py +9 -8
- rapidtide/tidepoolTemplate.py +142 -38
- rapidtide/tidepoolTemplate_alt.py +165 -44
- rapidtide/tidepoolTemplate_big.py +189 -52
- rapidtide/util.py +1217 -118
- rapidtide/voxelData.py +684 -37
- rapidtide/wiener.py +19 -12
- rapidtide/wiener2.py +113 -7
- rapidtide/wiener_doc.py +255 -0
- rapidtide/workflows/adjustoffset.py +105 -3
- rapidtide/workflows/aligntcs.py +85 -2
- rapidtide/workflows/applydlfilter.py +87 -10
- rapidtide/workflows/applyppgproc.py +522 -0
- rapidtide/workflows/atlasaverage.py +210 -47
- rapidtide/workflows/atlastool.py +100 -3
- rapidtide/workflows/calcSimFuncMap.py +294 -64
- rapidtide/workflows/calctexticc.py +201 -9
- rapidtide/workflows/ccorrica.py +97 -4
- rapidtide/workflows/cleanregressor.py +168 -29
- rapidtide/workflows/delayvar.py +163 -10
- rapidtide/workflows/diffrois.py +81 -3
- rapidtide/workflows/endtidalproc.py +144 -4
- rapidtide/workflows/fdica.py +195 -15
- rapidtide/workflows/filtnifti.py +70 -3
- rapidtide/workflows/filttc.py +74 -3
- rapidtide/workflows/fitSimFuncMap.py +206 -48
- rapidtide/workflows/fixtr.py +73 -3
- rapidtide/workflows/gmscalc.py +113 -3
- rapidtide/workflows/happy.py +813 -201
- rapidtide/workflows/happy2std.py +144 -12
- rapidtide/workflows/happy_parser.py +149 -8
- rapidtide/workflows/histnifti.py +118 -2
- rapidtide/workflows/histtc.py +84 -3
- rapidtide/workflows/linfitfilt.py +117 -4
- rapidtide/workflows/localflow.py +328 -28
- rapidtide/workflows/mergequality.py +79 -3
- rapidtide/workflows/niftidecomp.py +322 -18
- rapidtide/workflows/niftistats.py +174 -4
- rapidtide/workflows/pairproc.py +88 -2
- rapidtide/workflows/pairwisemergenifti.py +85 -2
- rapidtide/workflows/parser_funcs.py +1421 -40
- rapidtide/workflows/physiofreq.py +137 -11
- rapidtide/workflows/pixelcomp.py +208 -5
- rapidtide/workflows/plethquality.py +103 -21
- rapidtide/workflows/polyfitim.py +151 -11
- rapidtide/workflows/proj2flow.py +75 -2
- rapidtide/workflows/rankimage.py +111 -4
- rapidtide/workflows/rapidtide.py +272 -15
- rapidtide/workflows/rapidtide2std.py +98 -2
- rapidtide/workflows/rapidtide_parser.py +109 -9
- rapidtide/workflows/refineDelayMap.py +143 -33
- rapidtide/workflows/refineRegressor.py +682 -93
- rapidtide/workflows/regressfrommaps.py +152 -31
- rapidtide/workflows/resamplenifti.py +85 -3
- rapidtide/workflows/resampletc.py +91 -3
- rapidtide/workflows/retrolagtcs.py +98 -6
- rapidtide/workflows/retroregress.py +165 -9
- rapidtide/workflows/roisummarize.py +173 -5
- rapidtide/workflows/runqualitycheck.py +71 -3
- rapidtide/workflows/showarbcorr.py +147 -4
- rapidtide/workflows/showhist.py +86 -2
- rapidtide/workflows/showstxcorr.py +160 -3
- rapidtide/workflows/showtc.py +159 -3
- rapidtide/workflows/showxcorrx.py +184 -4
- rapidtide/workflows/showxy.py +185 -15
- rapidtide/workflows/simdata.py +262 -36
- rapidtide/workflows/spatialfit.py +77 -2
- rapidtide/workflows/spatialmi.py +251 -27
- rapidtide/workflows/spectrogram.py +305 -32
- rapidtide/workflows/synthASL.py +154 -3
- rapidtide/workflows/tcfrom2col.py +76 -2
- rapidtide/workflows/tcfrom3col.py +74 -2
- rapidtide/workflows/tidepool.py +2972 -133
- rapidtide/workflows/utils.py +19 -14
- rapidtide/workflows/utils_doc.py +293 -0
- rapidtide/workflows/variabilityizer.py +116 -3
- {rapidtide-3.0.10.dist-info → rapidtide-3.1.dist-info}/METADATA +10 -9
- {rapidtide-3.0.10.dist-info → rapidtide-3.1.dist-info}/RECORD +141 -122
- {rapidtide-3.0.10.dist-info → rapidtide-3.1.dist-info}/entry_points.txt +1 -0
- {rapidtide-3.0.10.dist-info → rapidtide-3.1.dist-info}/WHEEL +0 -0
- {rapidtide-3.0.10.dist-info → rapidtide-3.1.dist-info}/licenses/LICENSE +0 -0
- {rapidtide-3.0.10.dist-info → rapidtide-3.1.dist-info}/top_level.txt +0 -0
|
@@ -18,10 +18,13 @@
|
|
|
18
18
|
#
|
|
19
19
|
import argparse
|
|
20
20
|
import sys
|
|
21
|
+
from argparse import Namespace
|
|
22
|
+
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
|
21
23
|
|
|
22
24
|
import matplotlib.cm as cm
|
|
23
25
|
import numpy as np
|
|
24
26
|
import scipy as sp
|
|
27
|
+
from numpy.typing import NDArray
|
|
25
28
|
from scipy.signal import correlate
|
|
26
29
|
from scipy.stats import pearsonr
|
|
27
30
|
|
|
@@ -40,9 +43,31 @@ DEFAULT_SIGMAMAX = 1000.0
|
|
|
40
43
|
DEFAULT_SIGMAMIN = 0.25
|
|
41
44
|
|
|
42
45
|
|
|
43
|
-
def _get_parser():
|
|
46
|
+
def _get_parser() -> Any:
|
|
44
47
|
"""
|
|
45
|
-
Argument parser for showxcorrx
|
|
48
|
+
Argument parser for showxcorrx.
|
|
49
|
+
|
|
50
|
+
This function constructs and returns an `argparse.ArgumentParser` object configured
|
|
51
|
+
to handle command-line arguments for the `showxcorrx` utility. It supports a wide
|
|
52
|
+
range of options for loading time series data, preprocessing, cross-correlation
|
|
53
|
+
computation, and output formatting.
|
|
54
|
+
|
|
55
|
+
Returns
|
|
56
|
+
-------
|
|
57
|
+
argparse.ArgumentParser
|
|
58
|
+
Configured argument parser for `showxcorrx`.
|
|
59
|
+
|
|
60
|
+
Notes
|
|
61
|
+
-----
|
|
62
|
+
The parser includes groups for general options, preprocessing, similarity function
|
|
63
|
+
options, output settings, and debugging. It supports optional arguments such as
|
|
64
|
+
sample rate specification, data filtering, detrending, correlation weighting,
|
|
65
|
+
and plotting controls.
|
|
66
|
+
|
|
67
|
+
Examples
|
|
68
|
+
--------
|
|
69
|
+
>>> parser = _get_parser()
|
|
70
|
+
>>> args = parser.parse_args()
|
|
46
71
|
"""
|
|
47
72
|
parser = argparse.ArgumentParser(
|
|
48
73
|
prog="showxcorrx",
|
|
@@ -317,13 +342,168 @@ def _get_parser():
|
|
|
317
342
|
return parser
|
|
318
343
|
|
|
319
344
|
|
|
320
|
-
def printthresholds(pcts, thepercentiles, labeltext):
|
|
345
|
+
def printthresholds(pcts: Any, thepercentiles: Any, labeltext: Any) -> None:
|
|
346
|
+
"""
|
|
347
|
+
Print thresholds with corresponding percentiles.
|
|
348
|
+
|
|
349
|
+
This function prints a formatted list of thresholds along with their
|
|
350
|
+
corresponding percentile values for statistical analysis reporting.
|
|
351
|
+
|
|
352
|
+
Parameters
|
|
353
|
+
----------
|
|
354
|
+
pcts : Any
|
|
355
|
+
Array or list of percentile values to be printed
|
|
356
|
+
thepercentiles : Any
|
|
357
|
+
Array or list of percentile thresholds (typically between 0 and 1)
|
|
358
|
+
labeltext : Any
|
|
359
|
+
Text label to be printed before the threshold values
|
|
360
|
+
|
|
361
|
+
Returns
|
|
362
|
+
-------
|
|
363
|
+
None
|
|
364
|
+
This function prints to stdout and does not return any value
|
|
365
|
+
|
|
366
|
+
Notes
|
|
367
|
+
-----
|
|
368
|
+
The function formats the output to show "p < threshold: value" format
|
|
369
|
+
where the threshold is calculated as 1.0 - thepercentiles[i].
|
|
370
|
+
|
|
371
|
+
Examples
|
|
372
|
+
--------
|
|
373
|
+
>>> printthresholds([0.05, 0.01], [0.95, 0.99], "Significance Levels:")
|
|
374
|
+
Significance Levels:
|
|
375
|
+
p < 0.050 : 0.05
|
|
376
|
+
p < 0.010 : 0.01
|
|
377
|
+
"""
|
|
321
378
|
print(labeltext)
|
|
322
379
|
for i in range(0, len(pcts)):
|
|
323
380
|
print("\tp <", "{:.3f}".format(1.0 - thepercentiles[i]), ": ", pcts[i])
|
|
324
381
|
|
|
325
382
|
|
|
326
|
-
def showxcorrx(args):
|
|
383
|
+
def showxcorrx(args: Any) -> None:
|
|
384
|
+
"""
|
|
385
|
+
Compute and display cross-correlation or mutual information between two time series.
|
|
386
|
+
|
|
387
|
+
This function performs cross-correlation or mutual information analysis between two
|
|
388
|
+
time series, with optional filtering, normalization, and statistical significance
|
|
389
|
+
testing. It supports various similarity metrics and can output results to files or
|
|
390
|
+
display plots.
|
|
391
|
+
|
|
392
|
+
Parameters
|
|
393
|
+
----------
|
|
394
|
+
args : argparse.Namespace
|
|
395
|
+
Command-line arguments containing parameters for the analysis. Expected attributes include:
|
|
396
|
+
- infilename1, infilename2 : str
|
|
397
|
+
File names for the two time series.
|
|
398
|
+
- display : bool
|
|
399
|
+
Whether to display plots.
|
|
400
|
+
- samplerate : float or str
|
|
401
|
+
Sampling rate of the time series. If "auto", defaults to 1.0 Hz.
|
|
402
|
+
- startpoint, endpoint : float
|
|
403
|
+
Time range to analyze.
|
|
404
|
+
- trimdata : bool
|
|
405
|
+
Whether to trim data to the shortest length.
|
|
406
|
+
- invert : bool
|
|
407
|
+
Whether to invert the second time series.
|
|
408
|
+
- theprefilter : object
|
|
409
|
+
Filter object for preprocessing data.
|
|
410
|
+
- detrendorder : int
|
|
411
|
+
Order of detrending for correlation normalization.
|
|
412
|
+
- windowfunc : str
|
|
413
|
+
Window function for correlation normalization.
|
|
414
|
+
- corrweighting : str
|
|
415
|
+
Weighting method for correlation.
|
|
416
|
+
- zeropadding : int
|
|
417
|
+
Zero padding for correlation.
|
|
418
|
+
- smoothingtime : float
|
|
419
|
+
Smoothing time for mutual information calculation.
|
|
420
|
+
- minorm : bool
|
|
421
|
+
Whether to normalize mutual information.
|
|
422
|
+
- similaritymetric : str
|
|
423
|
+
Similarity metric to use ("correlation", "mutualinfo", "hybrid").
|
|
424
|
+
- lagmin, lagmax : float
|
|
425
|
+
Minimum and maximum lag for analysis.
|
|
426
|
+
- absmaxsigma, absminsigma : float
|
|
427
|
+
Sigma thresholds for peak fitting.
|
|
428
|
+
- cepstral : bool
|
|
429
|
+
Whether to compute cepstral delay.
|
|
430
|
+
- calccoherence : bool
|
|
431
|
+
Whether to compute coherence.
|
|
432
|
+
- calccsd : bool
|
|
433
|
+
Whether to compute cross-spectral density.
|
|
434
|
+
- numestreps : int
|
|
435
|
+
Number of bootstrap replicates for significance testing.
|
|
436
|
+
- showprogressbar : bool
|
|
437
|
+
Whether to show progress bar during bootstrap.
|
|
438
|
+
- permutationmethod : str
|
|
439
|
+
Permutation method for bootstrap.
|
|
440
|
+
- nprocs : int
|
|
441
|
+
Number of processes for parallel computation.
|
|
442
|
+
- summarymode : bool
|
|
443
|
+
Whether to output in summary format.
|
|
444
|
+
- resoutputfile : str
|
|
445
|
+
Output file for results.
|
|
446
|
+
- label : str
|
|
447
|
+
Label for output.
|
|
448
|
+
- labelline : bool
|
|
449
|
+
Whether to include label in output.
|
|
450
|
+
- colors : str
|
|
451
|
+
Comma-separated list of colors for plots.
|
|
452
|
+
- linewidths : str
|
|
453
|
+
Comma-separated list of line widths for plots.
|
|
454
|
+
- legendloc : int
|
|
455
|
+
Legend location for plots.
|
|
456
|
+
- legends : str
|
|
457
|
+
Legend labels for plots.
|
|
458
|
+
- dolegend : bool
|
|
459
|
+
Whether to display legend.
|
|
460
|
+
- thetitle : str
|
|
461
|
+
Title for plots.
|
|
462
|
+
- showxax, showyax : bool
|
|
463
|
+
Whether to show x and y axes.
|
|
464
|
+
- xlabel, ylabel : str
|
|
465
|
+
Axis labels.
|
|
466
|
+
- outputfile : str
|
|
467
|
+
Output file for plot.
|
|
468
|
+
- saveres : int
|
|
469
|
+
Resolution for saved plots.
|
|
470
|
+
- corroutputfile : str
|
|
471
|
+
Output file for correlation data.
|
|
472
|
+
- debug : bool
|
|
473
|
+
Whether to print debug information.
|
|
474
|
+
- verbose : bool
|
|
475
|
+
Whether to print verbose output.
|
|
476
|
+
- fontscalefac : float
|
|
477
|
+
Font scaling factor for plots.
|
|
478
|
+
|
|
479
|
+
Returns
|
|
480
|
+
-------
|
|
481
|
+
None
|
|
482
|
+
This function does not return a value but may display plots or write output files.
|
|
483
|
+
|
|
484
|
+
Notes
|
|
485
|
+
-----
|
|
486
|
+
The function supports multiple similarity metrics:
|
|
487
|
+
- "correlation": Pearson correlation coefficient
|
|
488
|
+
- "mutualinfo": Mutual information
|
|
489
|
+
- "hybrid": Combination of both metrics
|
|
490
|
+
|
|
491
|
+
Examples
|
|
492
|
+
--------
|
|
493
|
+
>>> import argparse
|
|
494
|
+
>>> args = argparse.Namespace(
|
|
495
|
+
... infilename1='data1.txt',
|
|
496
|
+
... infilename2='data2.txt',
|
|
497
|
+
... display=True,
|
|
498
|
+
... samplerate=1.0,
|
|
499
|
+
... startpoint=0,
|
|
500
|
+
... endpoint=100,
|
|
501
|
+
... similaritymetric='correlation',
|
|
502
|
+
... lagmin=-10,
|
|
503
|
+
... lagmax=10
|
|
504
|
+
... )
|
|
505
|
+
>>> showxcorrx(args)
|
|
506
|
+
"""
|
|
327
507
|
# set some default values
|
|
328
508
|
zerooutbadfit = False
|
|
329
509
|
peakfittype = "gauss"
|
rapidtide/workflows/showxy.py
CHANGED
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
#
|
|
19
19
|
import argparse
|
|
20
20
|
import sys
|
|
21
|
+
from argparse import Namespace
|
|
22
|
+
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
|
21
23
|
|
|
22
24
|
import matplotlib.cm as cm
|
|
23
25
|
import numpy as np
|
|
@@ -36,12 +38,38 @@ from matplotlib.pyplot import (
|
|
|
36
38
|
ylabel,
|
|
37
39
|
ylim,
|
|
38
40
|
)
|
|
41
|
+
from numpy.typing import NDArray
|
|
39
42
|
from scipy.stats import linregress
|
|
40
43
|
|
|
41
44
|
import rapidtide.io as tide_io
|
|
42
45
|
|
|
43
46
|
|
|
44
|
-
def _get_parser():
|
|
47
|
+
def _get_parser() -> Any:
|
|
48
|
+
"""
|
|
49
|
+
Create and configure an argument parser for plotting xy data from text files.
|
|
50
|
+
|
|
51
|
+
This function sets up an `argparse.ArgumentParser` with a variety of options to
|
|
52
|
+
control how xy data is read from text files and plotted. It supports features such as
|
|
53
|
+
axis labels, range limits, title, output file saving, font scaling, legend handling,
|
|
54
|
+
color specification, and special plot types like Bland-Altman.
|
|
55
|
+
|
|
56
|
+
Returns
|
|
57
|
+
-------
|
|
58
|
+
argparse.ArgumentParser
|
|
59
|
+
Configured argument parser object ready to parse command-line arguments.
|
|
60
|
+
|
|
61
|
+
Notes
|
|
62
|
+
-----
|
|
63
|
+
The parser expects one or more text file names as positional arguments. Each file
|
|
64
|
+
should contain whitespace-separated x and y data, one point per line.
|
|
65
|
+
|
|
66
|
+
Examples
|
|
67
|
+
--------
|
|
68
|
+
>>> parser = _get_parser()
|
|
69
|
+
>>> args = parser.parse_args(['data.txt'])
|
|
70
|
+
>>> print(args.textfilenames)
|
|
71
|
+
['data.txt']
|
|
72
|
+
"""
|
|
45
73
|
# get the command line parameters
|
|
46
74
|
parser = argparse.ArgumentParser(
|
|
47
75
|
prog="showxy",
|
|
@@ -202,18 +230,71 @@ def _get_parser():
|
|
|
202
230
|
|
|
203
231
|
|
|
204
232
|
def bland_altman_plot(
|
|
205
|
-
data1,
|
|
206
|
-
data2,
|
|
207
|
-
usex=False,
|
|
208
|
-
identifier=None,
|
|
209
|
-
fontscalefac=1.0,
|
|
210
|
-
xrange=None,
|
|
211
|
-
yrange=None,
|
|
212
|
-
doannotate=True,
|
|
213
|
-
debug=False,
|
|
214
|
-
*args,
|
|
215
|
-
**kwargs,
|
|
216
|
-
):
|
|
233
|
+
data1: Any,
|
|
234
|
+
data2: Any,
|
|
235
|
+
usex: bool = False,
|
|
236
|
+
identifier: Optional[Any] = None,
|
|
237
|
+
fontscalefac: float = 1.0,
|
|
238
|
+
xrange: Optional[Any] = None,
|
|
239
|
+
yrange: Optional[Any] = None,
|
|
240
|
+
doannotate: bool = True,
|
|
241
|
+
debug: bool = False,
|
|
242
|
+
*args: Any,
|
|
243
|
+
**kwargs: Any,
|
|
244
|
+
) -> None:
|
|
245
|
+
"""
|
|
246
|
+
Create a Bland-Altman plot to compare two measurement methods.
|
|
247
|
+
|
|
248
|
+
This function generates a Bland-Altman plot, which is used to compare two
|
|
249
|
+
measurement methods by plotting the difference between the measurements
|
|
250
|
+
against their mean. It also computes and displays key statistics such as
|
|
251
|
+
mean difference, standard deviation of differences, and regression slopes.
|
|
252
|
+
|
|
253
|
+
Parameters
|
|
254
|
+
----------
|
|
255
|
+
data1 : array-like
|
|
256
|
+
First set of measurements (X-axis data if `usex=True`).
|
|
257
|
+
data2 : array-like
|
|
258
|
+
Second set of measurements (Y-axis data).
|
|
259
|
+
usex : bool, optional
|
|
260
|
+
If True, use `data1` as the X-axis values; otherwise, use the mean of
|
|
261
|
+
`data1` and `data2` as the X-axis values. Default is False.
|
|
262
|
+
identifier : optional
|
|
263
|
+
Identifier for the dataset, printed for reference. Default is None.
|
|
264
|
+
fontscalefac : float, optional
|
|
265
|
+
Scaling factor for font size in annotations. Default is 1.0.
|
|
266
|
+
xrange : array-like, optional
|
|
267
|
+
X-axis limits for the plot. Default is None.
|
|
268
|
+
yrange : array-like, optional
|
|
269
|
+
Y-axis limits for the plot. Default is None.
|
|
270
|
+
doannotate : bool, optional
|
|
271
|
+
If True, annotate the plot with mean difference and standard deviation.
|
|
272
|
+
Default is True.
|
|
273
|
+
debug : bool, optional
|
|
274
|
+
If True, print debug information. Default is False.
|
|
275
|
+
*args : tuple
|
|
276
|
+
Additional arguments passed to the scatter plot.
|
|
277
|
+
**kwargs : dict
|
|
278
|
+
Additional keyword arguments passed to the scatter plot.
|
|
279
|
+
|
|
280
|
+
Returns
|
|
281
|
+
-------
|
|
282
|
+
None
|
|
283
|
+
This function does not return a value but displays a plot.
|
|
284
|
+
|
|
285
|
+
Notes
|
|
286
|
+
-----
|
|
287
|
+
The Bland-Altman plot is useful for assessing the agreement between two
|
|
288
|
+
measurement methods. The plot includes horizontal lines indicating the mean
|
|
289
|
+
difference and ±2 standard deviations from the mean.
|
|
290
|
+
|
|
291
|
+
Examples
|
|
292
|
+
--------
|
|
293
|
+
>>> import numpy as np
|
|
294
|
+
>>> data1 = np.array([1, 2, 3, 4, 5])
|
|
295
|
+
>>> data2 = np.array([1.1, 2.2, 2.8, 4.1, 4.9])
|
|
296
|
+
>>> bland_altman_plot(data1, data2)
|
|
297
|
+
"""
|
|
217
298
|
# data1 is X, data2 is Y
|
|
218
299
|
data1 = np.asarray(data1)
|
|
219
300
|
data2 = np.asarray(data2)
|
|
@@ -268,7 +349,35 @@ def bland_altman_plot(
|
|
|
268
349
|
ylim(yrange)
|
|
269
350
|
|
|
270
351
|
|
|
271
|
-
def stringtorange(thestring):
|
|
352
|
+
def stringtorange(thestring: Any) -> None:
|
|
353
|
+
"""
|
|
354
|
+
Convert a comma-separated string to a tuple of floats representing a range.
|
|
355
|
+
|
|
356
|
+
Parameters
|
|
357
|
+
----------
|
|
358
|
+
thestring : Any
|
|
359
|
+
A string containing two comma-separated float values representing
|
|
360
|
+
the minimum and maximum values of a range.
|
|
361
|
+
|
|
362
|
+
Returns
|
|
363
|
+
-------
|
|
364
|
+
tuple of float
|
|
365
|
+
A tuple containing (min_value, max_value) as floats.
|
|
366
|
+
|
|
367
|
+
Notes
|
|
368
|
+
-----
|
|
369
|
+
This function expects exactly two comma-separated float values. If the
|
|
370
|
+
input string does not contain exactly two values or if the values cannot
|
|
371
|
+
be converted to floats, the program will exit with an error message.
|
|
372
|
+
|
|
373
|
+
Examples
|
|
374
|
+
--------
|
|
375
|
+
>>> stringtorange("1.5,10.0")
|
|
376
|
+
(1.5, 10.0)
|
|
377
|
+
|
|
378
|
+
>>> stringtorange("0,-5.5")
|
|
379
|
+
(0.0, -5.5)
|
|
380
|
+
"""
|
|
272
381
|
thelist = thestring.split(",")
|
|
273
382
|
if len(thelist) != 2:
|
|
274
383
|
print("range setting requires two comma separated floats - exiting")
|
|
@@ -286,7 +395,68 @@ def stringtorange(thestring):
|
|
|
286
395
|
return (themin, themax)
|
|
287
396
|
|
|
288
397
|
|
|
289
|
-
def showxy(args):
|
|
398
|
+
def showxy(args: Any) -> None:
|
|
399
|
+
"""
|
|
400
|
+
Display or save xy data plots based on command-line arguments.
|
|
401
|
+
|
|
402
|
+
This function reads data from text files and plots the corresponding x and y vectors.
|
|
403
|
+
It supports multiple plot types including line plots, bar plots, and Bland-Altman plots.
|
|
404
|
+
The function also handles legend, title, axis labels, and output file saving.
|
|
405
|
+
|
|
406
|
+
Parameters
|
|
407
|
+
----------
|
|
408
|
+
args : Any
|
|
409
|
+
An object containing various arguments for plotting, including:
|
|
410
|
+
- `textfilenames`: List of text files containing data vectors.
|
|
411
|
+
- `colors`: Comma-separated string of color names for plotting.
|
|
412
|
+
- `legends`: Comma-separated string of legend labels.
|
|
413
|
+
- `legendloc`: Location of the legend.
|
|
414
|
+
- `dobars`: Boolean indicating whether to plot bar charts.
|
|
415
|
+
- `blandaltman`: Boolean indicating whether to use Bland-Altman plot.
|
|
416
|
+
- `usex`: Used in Bland-Altman plot.
|
|
417
|
+
- `fontscalefac`: Scaling factor for font sizes.
|
|
418
|
+
- `xrange`: X-axis range.
|
|
419
|
+
- `yrange`: Y-axis range.
|
|
420
|
+
- `doannotate`: Boolean indicating whether to annotate points.
|
|
421
|
+
- `debug`: Boolean for debugging output.
|
|
422
|
+
- `usepoints`: Boolean for plotting points instead of lines.
|
|
423
|
+
- `thetitle`: Title of the plot.
|
|
424
|
+
- `thexlabel`: X-axis label.
|
|
425
|
+
- `theylabel`: Y-axis label.
|
|
426
|
+
- `outputfile`: Output file name for saving the plot.
|
|
427
|
+
- `saveres`: Resolution for saved figure.
|
|
428
|
+
|
|
429
|
+
Returns
|
|
430
|
+
-------
|
|
431
|
+
None
|
|
432
|
+
This function does not return any value. It either displays the plot or saves it to a file.
|
|
433
|
+
|
|
434
|
+
Notes
|
|
435
|
+
-----
|
|
436
|
+
- If `dobars` is True, bar plots are displayed using light gray bars.
|
|
437
|
+
- If `blandaltman` is True, a Bland-Altman plot is generated.
|
|
438
|
+
- If neither `dobars` nor `blandaltman` is True, line plots are displayed.
|
|
439
|
+
- If `colors` is not provided, colors are selected from the `nipy_spectral` colormap.
|
|
440
|
+
- If `outputfile` is None, the plot is displayed using `matplotlib.pyplot.show()`.
|
|
441
|
+
|
|
442
|
+
Examples
|
|
443
|
+
--------
|
|
444
|
+
>>> args = argparse.Namespace(
|
|
445
|
+
... textfilenames=['data1.txt', 'data2.txt'],
|
|
446
|
+
... colors='red,blue',
|
|
447
|
+
... legends='Dataset1, Dataset2',
|
|
448
|
+
... legendloc='upper right',
|
|
449
|
+
... dobars=False,
|
|
450
|
+
... blandaltman=False,
|
|
451
|
+
... usepoints=False,
|
|
452
|
+
... thetitle='My Plot',
|
|
453
|
+
... thexlabel='X-axis',
|
|
454
|
+
... theylabel='Y-axis',
|
|
455
|
+
... outputfile='output.png',
|
|
456
|
+
... saveres=300
|
|
457
|
+
... )
|
|
458
|
+
>>> showxy(args)
|
|
459
|
+
"""
|
|
290
460
|
# process the file list
|
|
291
461
|
textfilename = []
|
|
292
462
|
for thefile in args.textfilenames:
|