File size: 1,502 Bytes
ea4eb5a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3
"""
Create JSON file for ACDC QC software with patient folder paths as keys
"""

import json
from pathlib import Path

def create_acdc_json():
    # Base directory for ACDC data (output of rename_acdc_specific.py)
    base_dir = Path("/mnt/storage/home/ym1413/QC_data_preprocessing/sabotaged_dataset")

    # Create dictionary with patient folders as keys
    acdc_data = {}

    # Get all patient directories
    patient_dirs = sorted([d for d in base_dir.iterdir() if d.is_dir() and d.name.startswith('patient')])

    for patient_dir in patient_dirs:
        # Remove base path /mnt/storage/home/ym1413 from the key
        key = str(patient_dir).replace("/mnt/storage/home/ym1413", "")

        # Extract patient ID from folder name
        patient_id = patient_dir.name

        # Create entry for this patient - just the key with empty dict for QC software to populate
        acdc_data[key] = {}

    # Save to JSON file
    output_file = Path("/mnt/storage/home/ym1413/QC_data_preprocessing/acdc_qc_dataset.json")

    with open(output_file, 'w') as f:
        json.dump(acdc_data, f, indent=4, sort_keys=True)

    print(f"Created JSON file with {len(acdc_data)} patient entries")
    print(f"Output saved to: {output_file}")

    # Show first few entries as preview
    print("\nFirst 3 entries:")
    for i, key in enumerate(list(acdc_data.keys())[:3]):
        print(f"\nEntry {i+1}:")
        print(f"  Key: {key}")

if __name__ == "__main__":
    create_acdc_json()