Skip to content

Commit 026f81f

Browse files
authored
Merge pull request #62 from KumarLabJax/YODA-193-add-docstrings-to-nextflow-functions-modules-and-workflows
Add docstrings to nextflow functions, modules, and workflows
2 parents 71c870b + 7b6e41b commit 026f81f

15 files changed

+616
-29
lines changed

nextflow/modules/fecal_boli.nf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* This module contains process definitions for fecal boli prediction and feature calculations.
3+
*/
4+
5+
/**
6+
* Predicts fecal boli in the video at minute intervals.
7+
*
8+
* @param tuple
9+
* - video_file The input video file.
10+
* - in_pose The input pose file.
11+
*
12+
* @return tuple files
13+
* - Path to the original video file.
14+
* - Modified pose file with fecal boli predictions.
15+
*/
116
process PREDICT_FECAL_BOLI {
217
label "gpu"
318
label "tracking"
@@ -16,6 +31,15 @@ process PREDICT_FECAL_BOLI {
1631
"""
1732
}
1833

34+
/**
35+
* Extracts fecal boli features from the pose data.
36+
*
37+
* @param tuple
38+
* - video_file The input video file.
39+
* - in_pose The input pose file.
40+
*
41+
* @return fecal_boli The generated fecal boli feature CSV file.
42+
*/
1943
process EXTRACT_FECAL_BOLI_BINS {
2044
label "tracking"
2145
label "r_fboli_extract"

nextflow/modules/flexibility.nf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/**
2+
* This module contains process definitions for generating flexibility metrics.
3+
* These metrics were published in https://doi.org/10.1038/s43587-022-00266-0
4+
*/
5+
6+
/**
7+
* Generates flexibility index metrics from pose data.
8+
*
9+
* @param tuple
10+
* - video_file The input video file.
11+
* - pose_file The input pose file.
12+
*
13+
* @return tuple files
14+
* - Path to the generated angles CSV file.
15+
* - Path to the generated dAC CSV file.
16+
* - Path to the generated dB CSV file.
17+
* - Path to the generated flexdexraw CSV file.
18+
*/
119
process GENERATE_FLEXIBILITY_INDEX {
220
label "frailty"
321
label "cpu"
@@ -32,6 +50,16 @@ process GENERATE_FLEXIBILITY_INDEX {
3250
"""
3351
}
3452

53+
/**
54+
* Generates rear paw width metrics from pose data.
55+
*
56+
* @param tuple
57+
* - video_file The input video file.
58+
* - pose_file The input pose file.
59+
*
60+
* @return rearpaw Path to the generated rear paw width CSV file.
61+
* @return rearpawsave Path to the generated rear paw save CSV file.
62+
*/
3563
process GENERATE_REAR_PAW_WIDTH {
3664
label "frailty"
3765
label "cpu"

nextflow/modules/gait.nf

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/**
2+
* This module contains process definitions for gait analysis.
3+
*/
4+
5+
/**
6+
* Generates gait statistics from pose data.
7+
*
8+
* @param tuple
9+
* - video_file The input video file.
10+
* - pose_file The input pose file.
11+
*
12+
* @return gait_file The generated gait statistics file.
13+
*/
114
process GENERATE_GAIT_H5 {
215
label "gait"
316
label "cpu"
@@ -24,7 +37,15 @@ process GENERATE_GAIT_H5 {
2437
"""
2538
}
2639

27-
40+
/**
41+
* Generates gait bin files from gait statistics.
42+
*
43+
* @param tuple
44+
* - gait_file The input gait statistics file.
45+
* - speed_bin The speed bin size for generating gait bins.
46+
*
47+
* @return gait_bin_csv The generated gait bin CSV file.
48+
*/
2849
process GENERATE_GAIT_BIN {
2950
label "gait"
3051
label "cpu"

nextflow/modules/jabs_classifiers.nf

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* This module contains process definitions related to JABS classifiers.
3+
*/
4+
5+
/**
6+
* Calculates features for JABS classifiers.
7+
*
8+
* @param tuple
9+
* - video_file The input video file.
10+
* - in_pose The input pose file.
11+
*
12+
* @return tuple files
13+
* - Path to the original pose file.
14+
* - Path to the generated feature cache directory.
15+
*/
116
process GENERATE_FEATURE_CACHE {
217
// This process will correct pose pathing to a v6 file
318
label "jabs_classify"
@@ -23,6 +38,20 @@ process GENERATE_FEATURE_CACHE {
2338
"""
2439
}
2540

41+
/**
42+
* Predicts behaviors using JABS classifiers.
43+
*
44+
* @param tuple
45+
* - in_pose The input pose file.
46+
* - feature_cache The directory containing the generated features.
47+
* @param classifiers A map of classifiers:
48+
* - <classifier_name>: classifier parameter maps (not used by this process)
49+
*
50+
* @return tuple files
51+
* - Path to the original pose file.
52+
* - Path to the feature cache directory.
53+
* - Path to the generated behavior file. All behavior predictions are stored in a single file.
54+
*/
2655
process PREDICT_CLASSIFIERS {
2756
label "jabs_classify"
2857
label "cpu"
@@ -46,25 +75,53 @@ process PREDICT_CLASSIFIERS {
4675
"""
4776
}
4877

78+
/**
79+
* Generates behavior tables from pose file, feature file, and prediction file.
80+
*
81+
* @param tuple
82+
* - in_pose The input pose file.
83+
* - feature_cache The directory containing the generated features.
84+
* - behavior_files The behavior prediction file.
85+
* @param classifiers A map of classifiers:
86+
* - <classifier_name>: classifier parameter maps:
87+
* - stitch_value: the gap size for stitching behavior bouts
88+
* - filter_value: the minimum length for behavior bouts
89+
*
90+
* @return tuple files
91+
* - Path to the generated behavior bout file.
92+
* - Path to the generated behavior summary file.
93+
*/
4994
process GENERATE_BEHAVIOR_TABLES {
5095
label "jabs_postprocess"
5196
label "cpu"
5297
label "r_jabs_tablegen"
5398

5499
input:
55100
tuple path(in_pose), path(feature_cache), path(behavior_files)
56-
val classifier
101+
val classifiers
57102

58103
output:
59104
tuple path("${in_pose.baseName}*_bouts.csv"), path("${in_pose.baseName}*_summaries.csv"), emit: files
60105

61106
script:
62107
"""
63-
behavior_command="--behavior ${classifier.collect { entry -> "$entry.key --stitch_gap $entry.value.stitch_value --min_bout_length $entry.value.filter_value" }.join(' --behavior ')}"
108+
behavior_command="--behavior ${classifiers.collect { entry -> "$entry.key --stitch_gap $entry.value.stitch_value --min_bout_length $entry.value.filter_value" }.join(' --behavior ')}"
64109
python3 /JABS-postprocess/generate_behavior_tables.py --project_folder . --feature_folder . --out_prefix ${in_pose.baseName} --out_bin_size 5 \${behavior_command}
65110
"""
66111
}
67112

113+
/**
114+
* Generates heuristic classifier predictions.
115+
*
116+
* @param tuple
117+
* - in_pose The input pose file.
118+
* - feature_cache The directory containing the generated features.
119+
* @param heuristic_classifiers A list of heuristic classifier configuration files.
120+
*
121+
* @return tuple files
122+
* - Path to the generated bout file.
123+
* - Path to the generated summary file.
124+
*/
68125
process PREDICT_HEURISTICS {
69126
label "jabs_postprocess"
70127
label "cpu"
@@ -87,6 +144,14 @@ process PREDICT_HEURISTICS {
87144
"""
88145
}
89146

147+
/**
148+
* Converts a behavior summary table to features.
149+
*
150+
* @param in_summary_table The input behavior summary table.
151+
* @param bin_size The bin size for feature extraction.
152+
*
153+
* @return features The generated feature file.
154+
*/
90155
process BEHAVIOR_TABLE_TO_FEATURES {
91156
label "jabs_table_convert"
92157
label "r_jabs_table_convert"

nextflow/modules/manual_correction.nf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/**
2+
* This module contains process definitions related to manually correcting pose data using SLEAP.
3+
*/
4+
5+
/**
6+
* Extracts a frame from a video as a png image.
7+
*
8+
* @param tuple
9+
* - video The input video file.
10+
* - pose_file The input pose file (not used in this process).
11+
* @param frame_index The index of the frame to extract.
12+
*
13+
* @return frame A png image of the extracted frame.
14+
*/
115
process EXTRACT_VIDEO_FRAME {
216
label "sleap"
317

@@ -14,6 +28,13 @@ process EXTRACT_VIDEO_FRAME {
1428
"""
1529
}
1630

31+
/**
32+
* Adds a set of frames to a new SLEAP project file for arena corner annotation.
33+
*
34+
* @param video_frames A list of png images to be added to the SLEAP project.
35+
*
36+
* @return sleap_file The generated SLEAP project file containing the frames and arena corner skeleton for annotation.
37+
*/
1738
process ADD_EXAMPLES_TO_SLEAP {
1839
label "sleap"
1940

@@ -48,6 +69,14 @@ process ADD_EXAMPLES_TO_SLEAP {
4869
"""
4970
}
5071

72+
/**
73+
* Integrates SLEAP corner annotations into a pose file.
74+
*
75+
* @param pose_file The input pose file to be corrected.
76+
* @param sleap_file The SLEAP project file containing the corner annotations.
77+
*
78+
* @return pose_file The corrected pose file with integrated corner annotations.
79+
*/
5180
process INTEGRATE_SLEAP_CORNER_ANNOTATIONS {
5281
label "sleap_io"
5382

nextflow/modules/multi_mouse.nf

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/**
2+
* Predicts multi-mouse segmentation.
3+
*
4+
* @param tuple
5+
* - video_file The input video file
6+
* - in_pose The input pose file
7+
*
8+
* @return tuple files
9+
* - Path to the original video file.
10+
* - Modified pose file with multi-mouse segmentation predicted.
11+
*/
112
process PREDICT_MULTI_MOUSE_SEGMENTATION {
213
label "gpu_long"
314
label "tracking"
@@ -16,6 +27,17 @@ process PREDICT_MULTI_MOUSE_SEGMENTATION {
1627
"""
1728
}
1829

30+
/**
31+
* Predicts multi-mouse keypoints.
32+
*
33+
* @param tuple
34+
* - video_file The input video file
35+
* - in_pose The input pose file
36+
*
37+
* @return tuple files
38+
* - Path to the original video file.
39+
* - Modified pose file with multi-mouse keypoints predicted.
40+
*/
1941
process PREDICT_MULTI_MOUSE_KEYPOINTS {
2042
label "gpu_long"
2143
label "tracking"
@@ -34,6 +56,17 @@ process PREDICT_MULTI_MOUSE_KEYPOINTS {
3456
"""
3557
}
3658

59+
/**
60+
* Predicts multi-mouse identity.
61+
*
62+
* @param tuple
63+
* - video_file The input video file
64+
* - in_pose The input pose file
65+
*
66+
* @return tuple files
67+
* - Path to the original video file.
68+
* - Modified pose file with multi-mouse identity predicted.
69+
*/
3770
process PREDICT_MULTI_MOUSE_IDENTITY {
3871
label "gpu"
3972
label "tracking"
@@ -52,6 +85,18 @@ process PREDICT_MULTI_MOUSE_IDENTITY {
5285
"""
5386
}
5487

88+
/**
89+
* Generates multi-mouse tracklets from the pose, segmentaiton, and identity data.
90+
*
91+
* @param tuple
92+
* - video_file The input video file
93+
* - in_pose The input pose file
94+
* - num_animals The number of animals to generate tracklets for
95+
*
96+
* @return tuple files
97+
* - Path to the original video file.
98+
* - Modified pose file with multi-mouse tracklets generated.
99+
*/
55100
process GENERATE_MULTI_MOUSE_TRACKLETS {
56101
label "cpu"
57102
label "tracking"

0 commit comments

Comments
 (0)