Skip to content

Commit 4438bf9

Browse files
committed
format with black
1 parent 5e44278 commit 4438bf9

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

petdeface/petdeface.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,6 @@ def main(): # noqa: max-complexity: 12
12711271
print("=" * 60)
12721272

12731273
try:
1274-
12751274
# Determine the defaced directory based on placement
12761275
if args.placement == "adjacent":
12771276
defaced_dir = args.bids_dir.parent / f"{args.bids_dir.name}_defaced"
@@ -1291,9 +1290,7 @@ def main(): # noqa: max-complexity: 12
12911290
faced_dir=str(args.bids_dir),
12921291
defaced_dir=str(defaced_dir),
12931292
subject=(
1294-
" ".join(args.participant_label)
1295-
if args.participant_label
1296-
else None
1293+
" ".join(args.participant_label) if args.participant_label else None
12971294
),
12981295
open_browser=args.open_browser,
12991296
)
@@ -1305,9 +1302,7 @@ def main(): # noqa: max-complexity: 12
13051302

13061303
except Exception as e:
13071304
print(f"\nError generating QA reports: {e}")
1308-
print(
1309-
"QA report generation failed, but defacing completed successfully."
1310-
)
1305+
print("QA report generation failed, but defacing completed successfully.")
13111306

13121307

13131308
if __name__ == "__main__":

petdeface/qa.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
from pathlib import Path
2323

2424

25-
26-
27-
2825
def preprocess_single_subject(s, output_dir):
2926
"""Preprocess a single subject's images (for parallel processing)."""
3027
temp_dir = os.path.join(output_dir, "temp_3d_images")

tests/test_dir_layouts.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def test_participant_exclusion():
129129
"""Test that participant exclusion works correctly by excluding sub-02"""
130130
with tempfile.TemporaryDirectory() as temp_dir:
131131
test_dir = Path(temp_dir)
132-
132+
133133
# Create the test directory and copy our data
134134
shutil.copytree(data_dir, test_dir / "participant_exclusion")
135135

@@ -145,37 +145,45 @@ def test_participant_exclusion():
145145

146146
# Check the final defaced dataset directory
147147
final_defaced_dir = test_dir / "participant_exclusion_defaced"
148-
148+
149149
# Count files in the final defaced dataset
150150
all_files = list(final_defaced_dir.rglob("*"))
151151
all_files = [f for f in all_files if f.is_file()] # Only files, not directories
152-
152+
153153
# Count files by subject
154154
sub01_files = [f for f in all_files if "sub-01" in str(f)]
155155
sub02_files = [f for f in all_files if "sub-02" in str(f)]
156-
156+
157157
print(f"Total files in defaced dataset: {len(all_files)}")
158158
print(f"sub-01 files: {len(sub01_files)}")
159159
print(f"sub-02 files: {len(sub02_files)}")
160-
160+
161161
# Verify that sub-02 does NOT appear anywhere in the final defaced dataset
162-
assert len(sub02_files) == 0, f"sub-02 should be completely excluded from final defaced dataset, but found {len(sub02_files)} files: {[str(f) for f in sub02_files]}"
163-
162+
assert (
163+
len(sub02_files) == 0
164+
), f"sub-02 should be completely excluded from final defaced dataset, but found {len(sub02_files)} files: {[str(f) for f in sub02_files]}"
165+
164166
# Verify that sub-01 exists and was processed
165167
assert len(sub01_files) > 0, "sub-01 should exist in final defaced dataset"
166-
assert (final_defaced_dir / "sub-01").exists(), "sub-01 directory should exist in final defaced dataset"
167-
168+
assert (
169+
final_defaced_dir / "sub-01"
170+
).exists(), "sub-01 directory should exist in final defaced dataset"
171+
168172
# Verify processing artifacts exist for sub-01 in derivatives
169173
derivatives_dir = final_defaced_dir / "derivatives" / "petdeface"
170174
if derivatives_dir.exists():
171175
sub01_defacemasks = list(derivatives_dir.glob("**/sub-01*defacemask*"))
172176
sub01_lta_files = list(derivatives_dir.glob("**/sub-01*.lta"))
173-
177+
174178
print(f"sub-01 defacemasks found: {len(sub01_defacemasks)}")
175179
print(f"sub-01 lta files found: {len(sub01_lta_files)}")
176-
177-
assert len(sub01_defacemasks) > 0, "sub-01 should have been processed and have defacemasks"
178-
assert len(sub01_lta_files) > 0, "sub-01 should have been processed and have lta registration files"
180+
181+
assert (
182+
len(sub01_defacemasks) > 0
183+
), "sub-01 should have been processed and have defacemasks"
184+
assert (
185+
len(sub01_lta_files) > 0
186+
), "sub-01 should have been processed and have lta registration files"
179187

180188

181189
def test_no_anat():

0 commit comments

Comments
 (0)