d3v-26 commited on
Commit
d3309cc
·
verified ·
1 Parent(s): 8224e41

Upload test_models.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. test_models.py +277 -352
test_models.py CHANGED
@@ -1,354 +1,279 @@
1
- #!/usr/bin/env python3
2
- """
3
- Test script to validate all BrainSegFounder model weights.
4
- This script checks if models can be loaded and perform inference.
5
- """
6
-
7
- import os
8
- import sys
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  import torch
 
 
10
  from argparse import Namespace
11
- from pathlib import Path
12
-
13
- try:
14
- from huggingface_hub import hf_hub_download
15
- HF_AVAILABLE = True
16
- except ImportError:
17
- HF_AVAILABLE = False
18
- print("Warning: huggingface_hub not available. Will only test local files.")
19
-
20
- try:
21
- from monai.networks.nets import SwinUNETR
22
- MONAI_AVAILABLE = True
23
- except ImportError:
24
- MONAI_AVAILABLE = False
25
- print("Warning: MONAI not available. Install with: pip install git+https://github.com/Project-MONAI/MONAI.git@a23c7f54")
26
-
27
- # Try to import SSL_Head
28
- try:
29
- from SSL_Head import SSLHead
30
- SSL_HEAD_AVAILABLE = True
31
- except ImportError:
32
- SSL_HEAD_AVAILABLE = False
33
- print("Warning: SSL_Head.py not found in current directory or Python path.")
34
-
35
-
36
- class ModelTester:
37
- """Test suite for BrainSegFounder models."""
38
-
39
- def __init__(self, use_local=True, use_hf=False):
40
- """
41
- Initialize the model tester.
42
-
43
- Args:
44
- use_local: Test local model files
45
- use_hf: Download and test from Hugging Face
46
- """
47
- self.use_local = use_local
48
- self.use_hf = use_hf
49
- self.repo_id = "smilelab/BrainSegFounder"
50
- self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
51
- print(f"Using device: {self.device}")
52
- print("=" * 70)
53
-
54
- def test_ssl_pretrain_model(self, model_path, model_name):
55
- """Test SSL pretraining models (SSLHead)."""
56
- if not SSL_HEAD_AVAILABLE:
57
- print(f"⚠ Skipping {model_name}: SSL_Head not available")
58
- return False
59
-
60
- print(f"\n[Testing] {model_name}")
61
- print("-" * 70)
62
-
63
- try:
64
- # Configure model
65
- args = Namespace(
66
- in_channels=2,
67
- spatial_dims=3,
68
- bottleneck_depth=768,
69
- feature_size=48,
70
- num_swin_blocks_per_stage=[2, 2, 2, 2],
71
- num_heads_per_stage=[3, 6, 12, 24],
72
- dropout_path_rate=0.0,
73
- use_checkpoint=False
74
- )
75
-
76
- # Load model
77
- print(f" Loading model from: {model_path}")
78
- model = SSLHead(args)
79
- checkpoint = torch.load(model_path, map_location="cpu")
80
-
81
- # Handle checkpoint format (may be nested under 'state_dict' key)
82
- if isinstance(checkpoint, dict) and 'state_dict' in checkpoint:
83
- print(f" Detected checkpoint format with nested state_dict")
84
- state_dict = checkpoint['state_dict']
85
- else:
86
- state_dict = checkpoint
87
-
88
- model.load_state_dict(state_dict)
89
- model.to(self.device)
90
- model.eval()
91
-
92
- # Test forward pass with dummy input
93
- print(f" Creating dummy input (2 channels, 96x96x96)...")
94
- dummy_input = torch.randn(1, 2, 96, 96, 96).to(self.device)
95
-
96
- print(f" Running forward pass...")
97
- with torch.no_grad():
98
- x_rot, x_contrastive, x_rec = model(dummy_input)
99
-
100
- # Validate outputs
101
- assert x_rot.shape == (1, 4), f"Expected rotation output shape (1, 4), got {x_rot.shape}"
102
- assert x_contrastive.shape == (1, 512), f"Expected contrastive output shape (1, 512), got {x_contrastive.shape}"
103
- assert x_rec.shape == (1, 2, 96, 96, 96), f"Expected reconstruction output shape (1, 2, 96, 96, 96), got {x_rec.shape}"
104
-
105
- print(f" ✓ Rotation output shape: {x_rot.shape}")
106
- print(f" ✓ Contrastive output shape: {x_contrastive.shape}")
107
- print(f" ✓ Reconstruction output shape: {x_rec.shape}")
108
- print(f" ✓ Model parameters: {sum(p.numel() for p in model.parameters()):,}")
109
- print(f"✓ {model_name} passed all tests!")
110
-
111
- # Clean up
112
- del model, state_dict, dummy_input, x_rot, x_contrastive, x_rec
113
- if torch.cuda.is_available():
114
- torch.cuda.empty_cache()
115
-
116
- return True
117
-
118
- except Exception as e:
119
- print(f"✗ {model_name} failed: {str(e)}")
120
- return False
121
-
122
- def test_swinunetr_model(self, model_path, model_name):
123
- """Test finetuned segmentation models (SwinUNETR)."""
124
- if not MONAI_AVAILABLE:
125
- print(f"⚠ Skipping {model_name}: MONAI not available")
126
- return False
127
-
128
- print(f"\n[Testing] {model_name}")
129
- print("-" * 70)
130
-
131
- try:
132
- # Configure model
133
- depths = [2, 2, 2, 2]
134
- num_heads = [3, 6, 12, 24]
135
-
136
- print(f" Loading model from: {model_path}")
137
-
138
- # Try with img_size first (older MONAI versions)
139
- try:
140
- model = SwinUNETR(
141
- img_size=(96, 96, 96),
142
- in_channels=4,
143
- out_channels=3,
144
- feature_size=48,
145
- use_checkpoint=False,
146
- depths=depths,
147
- num_heads=num_heads
148
- )
149
- except TypeError:
150
- # Newer MONAI versions use spatial_size instead of img_size
151
- print(f" Using spatial_size parameter (newer MONAI)")
152
- model = SwinUNETR(
153
- spatial_size=(96, 96, 96),
154
- in_channels=4,
155
- out_channels=3,
156
- feature_size=48,
157
- use_checkpoint=False,
158
- depths=depths,
159
- num_heads=num_heads
160
- )
161
-
162
- checkpoint = torch.load(model_path, map_location="cpu")
163
-
164
- # Handle checkpoint format (may be nested under 'state_dict' key)
165
- if isinstance(checkpoint, dict) and 'state_dict' in checkpoint:
166
- print(f" Detected checkpoint format with nested state_dict")
167
- state_dict = checkpoint['state_dict']
168
- else:
169
- state_dict = checkpoint
170
-
171
- model.load_state_dict(state_dict)
172
- model.to(self.device)
173
- model.eval()
174
-
175
- # Test forward pass with dummy input
176
- print(f" Creating dummy input (4 channels, 96x96x96)...")
177
- dummy_input = torch.randn(1, 4, 96, 96, 96).to(self.device)
178
-
179
- print(f" Running forward pass...")
180
- with torch.no_grad():
181
- output = model(dummy_input)
182
-
183
- # Validate output
184
- assert output.shape == (1, 3, 96, 96, 96), f"Expected output shape (1, 3, 96, 96, 96), got {output.shape}"
185
-
186
- print(f" ✓ Output shape: {output.shape}")
187
- print(f" ✓ Model parameters: {sum(p.numel() for p in model.parameters()):,}")
188
- print(f"✓ {model_name} passed all tests!")
189
-
190
- # Clean up
191
- del model, state_dict, dummy_input, output
192
- if torch.cuda.is_available():
193
- torch.cuda.empty_cache()
194
-
195
- return True
196
-
197
- except Exception as e:
198
- print(f"✗ {model_name} failed: {str(e)}")
199
- return False
200
-
201
- def test_local_models(self):
202
- """Test all local model files."""
203
- print("\n" + "=" * 70)
204
- print("TESTING LOCAL MODEL FILES")
205
- print("=" * 70)
206
-
207
- models = {
208
- "model_weights_UKB-pretrain.pt": ("ssl", "UKB Pretrain"),
209
- "model_weights_BRATS-pretrain.pt": ("ssl", "BRATS Pretrain"),
210
- "model_weights_ATLAS-pretrain.pt": ("ssl", "ATLAS Pretrain"),
211
- "model_weights_BRATS-finetune.pt": ("swinunetr", "BRATS Finetune"),
212
- "model_weights_ATLAS-finetune.pt": ("swinunetr", "ATLAS Finetune"),
213
- }
214
-
215
- results = {}
216
- for filename, (model_type, display_name) in models.items():
217
- if not os.path.exists(filename):
218
- print(f"\n⚠ Skipping {display_name}: {filename} not found locally")
219
- results[display_name] = "not_found"
220
- continue
221
-
222
- if model_type == "ssl":
223
- success = self.test_ssl_pretrain_model(filename, display_name)
224
- else:
225
- success = self.test_swinunetr_model(filename, display_name)
226
-
227
- results[display_name] = "passed" if success else "failed"
228
-
229
- return results
230
-
231
- def test_huggingface_models(self):
232
- """Test models downloaded from Hugging Face."""
233
- if not HF_AVAILABLE:
234
- print("\n⚠ Skipping Hugging Face tests: huggingface_hub not installed")
235
- return {}
236
-
237
- print("\n" + "=" * 70)
238
- print("TESTING HUGGING FACE MODELS")
239
- print("=" * 70)
240
-
241
- models = {
242
- "model_weights_UKB-pretrain.pt": ("ssl", "UKB Pretrain (HF)"),
243
- "model_weights_BRATS-pretrain.pt": ("ssl", "BRATS Pretrain (HF)"),
244
- "model_weights_ATLAS-pretrain.pt": ("ssl", "ATLAS Pretrain (HF)"),
245
- "model_weights_BRATS-finetune.pt": ("swinunetr", "BRATS Finetune (HF)"),
246
- "model_weights_ATLAS-finetune.pt": ("swinunetr", "ATLAS Finetune (HF)"),
247
- }
248
-
249
- results = {}
250
- for filename, (model_type, display_name) in models.items():
251
- try:
252
- print(f"\n[Downloading] {display_name} from Hugging Face...")
253
- model_path = hf_hub_download(
254
- repo_id=self.repo_id,
255
- filename=filename,
256
- cache_dir=".hf_cache"
257
- )
258
-
259
- if model_type == "ssl":
260
- success = self.test_ssl_pretrain_model(model_path, display_name)
261
- else:
262
- success = self.test_swinunetr_model(model_path, display_name)
263
-
264
- results[display_name] = "passed" if success else "failed"
265
-
266
- except Exception as e:
267
- print(f"✗ Failed to download/test {display_name}: {str(e)}")
268
- results[display_name] = "failed"
269
-
270
- return results
271
-
272
- def print_summary(self, local_results, hf_results):
273
- """Print test summary."""
274
- print("\n" + "=" * 70)
275
- print("TEST SUMMARY")
276
- print("=" * 70)
277
-
278
- all_results = {}
279
- if local_results:
280
- print("\nLocal Models:")
281
- for name, status in local_results.items():
282
- symbol = "✓" if status == "passed" else "✗" if status == "failed" else "⚠"
283
- print(f" {symbol} {name}: {status}")
284
- all_results[name] = status
285
-
286
- if hf_results:
287
- print("\nHugging Face Models:")
288
- for name, status in hf_results.items():
289
- symbol = "✓" if status == "passed" else "✗"
290
- print(f" {symbol} {name}: {status}")
291
- all_results[name] = status
292
-
293
- # Overall statistics
294
- passed = sum(1 for s in all_results.values() if s == "passed")
295
- failed = sum(1 for s in all_results.values() if s == "failed")
296
- skipped = sum(1 for s in all_results.values() if s == "not_found")
297
- total = len(all_results)
298
-
299
- print(f"\nOverall: {passed}/{total} passed, {failed} failed, {skipped} skipped")
300
-
301
- return failed == 0 and passed > 0
302
-
303
-
304
- def main():
305
- """Main test function."""
306
- import argparse
307
-
308
- parser = argparse.ArgumentParser(
309
- description="Test BrainSegFounder model weights"
310
- )
311
- parser.add_argument(
312
- "--local",
313
- action="store_true",
314
- default=True,
315
- help="Test local model files (default: True)"
316
- )
317
- parser.add_argument(
318
- "--hf",
319
- action="store_true",
320
- help="Download and test models from Hugging Face"
321
- )
322
- parser.add_argument(
323
- "--no-local",
324
- action="store_true",
325
- help="Skip testing local files"
326
- )
327
-
328
- args = parser.parse_args()
329
-
330
- use_local = not args.no_local
331
- use_hf = args.hf
332
-
333
- if not use_local and not use_hf:
334
- print("Error: Must test either local or Hugging Face models (or both)")
335
- sys.exit(1)
336
-
337
- tester = ModelTester(use_local=use_local, use_hf=use_hf)
338
-
339
- local_results = {}
340
- hf_results = {}
341
-
342
- if use_local:
343
- local_results = tester.test_local_models()
344
-
345
- if use_hf:
346
- hf_results = tester.test_huggingface_models()
347
-
348
- success = tester.print_summary(local_results, hf_results)
349
-
350
- sys.exit(0 if success else 1)
351
-
352
-
353
- if __name__ == "__main__":
354
- main()
 
1
+ ---
2
+ license: other
3
+ license_name: uk-biobank-mta
4
+ license_link: https://www.ukbiobank.ac.uk/media/p3el3p0f/mta-v20-final-29mar2021-clean.pdf
5
+ tags:
6
+ - medical
7
+ - mri
8
+ - brain-segmentation
9
+ - self-supervised-learning
10
+ - swin-transformer
11
+ - monai
12
+ - uk-biobank
13
+ - brats
14
+ - atlas
15
+ pipeline_tag: image-segmentation
16
+ ---
17
+
18
+ # BrainSegFounder: UK Biobank Brain MRI Foundation Models
19
+
20
+ ## Overview
21
+
22
+ This repository contains pretrained model weights derived from UK Biobank MRI data and downstream medical imaging datasets. These weights correspond to the self-supervised pretraining and supervised finetuning stages described in the **BrainSegFounder** framework.
23
+
24
+ **Paper:** [BrainSegFounder: Self-supervised Learning for Brain MRI Segmentation](https://doi.org/10.1016/j.media.2024.103301)
25
+
26
+ **Please cite this paper if you use these model weights.**
27
+
28
+ ### Available Model Weights
29
+
30
+ This repository includes:
31
+
32
+ | Model File | Description | Training Data | Subjects |
33
+ |------------|-------------|---------------|----------|
34
+ | `model_weights_UKB-pretrain.pt` | SSL pretraining weights | UK Biobank MRI (fields 20252-20253) | ~41,000 |
35
+ | `model_weights_BRATS-pretrain.pt` | SSL pretraining weights | UKB + BraTS (multimodal MRI) | 42,470 |
36
+ | `model_weights_BRATS-finetune.pt` | SwinUNETR finetuning weights | BraTS tumor segmentation | 1,470 |
37
+ | `model_weights_ATLAS-pretrain.pt` | SSL pretraining weights | UKB + ATLAS v2.0 (multimodal MRI) | 42,271 |
38
+ | `model_weights_ATLAS-finetune.pt` | SwinUNETR finetuning weights | ATLAS stroke lesion segmentation | 1,271 |
39
+ | `SSL_Head.py` | Source code | SSL head implementation for pretraining | - |
40
+
41
+ This README provides instructions for loading the weights, architecture descriptions, dataset information, and required UK Biobank privacy/policy statements.
42
+
43
+
44
+ ## Quick Start
45
+
46
+ ### Installation
47
+
48
+ All models use MONAI components and require:
49
+
50
+ ```bash
51
+ pip install git+https://github.com/Project-MONAI/MONAI.git@a23c7f54
52
+ pip install torch
53
+ ```
54
+
55
+ ### Usage Examples
56
+
57
+ #### Loading UKB-only Pretraining Weights
58
+
59
+ ```python
60
+ import torch
61
+ from huggingface_hub import hf_hub_download
62
+ from SSL_Head import SSLHead # Download SSL_Head.py from this repo
63
+ from argparse import Namespace
64
+
65
+ # Download model weights
66
+ model_path = hf_hub_download(
67
+ repo_id="smilelab/BrainSegFounder",
68
+ filename="model_weights_UKB-pretrain.pt"
69
+ )
70
+
71
+ # Configure model
72
+ args = Namespace(
73
+ in_channels=2, # T1 + T2
74
+ spatial_dims=3,
75
+ bottleneck_depth=768,
76
+ feature_size=48,
77
+ num_swin_blocks_per_stage=[2,2,2,2],
78
+ num_heads_per_stage=[3,6,12,24],
79
+ dropout_path_rate=0.0,
80
+ use_checkpoint=False
81
+ )
82
+
83
+ # Load model
84
+ model = SSLHead(args)
85
+ checkpoint = torch.load(model_path, map_location="cpu")
86
+
87
+ # Extract state_dict (checkpoints have nested structure)
88
+ if isinstance(checkpoint, dict) and 'state_dict' in checkpoint:
89
+ state_dict = checkpoint['state_dict']
90
+ else:
91
+ state_dict = checkpoint
92
+
93
+ model.load_state_dict(state_dict)
94
+ model.eval()
95
+ ```
96
+
97
+ #### Loading Multimodal Pretraining Weights (UKB + BraTS/ATLAS)
98
+
99
+ ```python
100
  import torch
101
+ from huggingface_hub import hf_hub_download
102
+ from SSL_Head import SSLHead
103
  from argparse import Namespace
104
+
105
+ # Download BRATS or ATLAS pretrain weights
106
+ model_path = hf_hub_download(
107
+ repo_id="smilelab/BrainSegFounder",
108
+ filename="model_weights_BRATS-pretrain.pt" # or model_weights_ATLAS-pretrain.pt
109
+ )
110
+
111
+ args = Namespace(
112
+ in_channels=2,
113
+ spatial_dims=3,
114
+ bottleneck_depth=768,
115
+ feature_size=48,
116
+ num_swin_blocks_per_stage=[2,2,2,2],
117
+ num_heads_per_stage=[3,6,12,24],
118
+ dropout_path_rate=0.0,
119
+ use_checkpoint=False
120
+ )
121
+
122
+ model = SSLHead(args)
123
+ checkpoint = torch.load(model_path, map_location="cpu")
124
+
125
+ # Extract state_dict (checkpoints have nested structure)
126
+ if isinstance(checkpoint, dict) and 'state_dict' in checkpoint:
127
+ state_dict = checkpoint['state_dict']
128
+ else:
129
+ state_dict = checkpoint
130
+
131
+ model.load_state_dict(state_dict)
132
+ model.eval()
133
+ ```
134
+
135
+ #### Loading Finetuned Segmentation Weights (SwinUNETR)
136
+
137
+ ```python
138
+ import torch
139
+ from huggingface_hub import hf_hub_download
140
+ from monai.networks.nets import SwinUNETR
141
+
142
+ # Download BRATS or ATLAS finetune weights
143
+ model_path = hf_hub_download(
144
+ repo_id="smilelab/BrainSegFounder",
145
+ filename="model_weights_BRATS-finetune.pt" # or model_weights_ATLAS-finetune.pt
146
+ )
147
+
148
+ # Configure SwinUNETR
149
+ depths = [2, 2, 2, 2]
150
+ num_heads = [3, 6, 12, 24]
151
+
152
+ # MONAI 1.x+ uses spatial_dims=3, older versions use img_size=(96,96,96)
153
+ model = SwinUNETR(
154
+ spatial_dims=3, # Use img_size=(96, 96, 96) for MONAI 0.x
155
+ in_channels=4,
156
+ out_channels=3,
157
+ feature_size=48,
158
+ use_checkpoint=False,
159
+ depths=depths,
160
+ num_heads=num_heads
161
+ )
162
+
163
+ checkpoint = torch.load(model_path, map_location="cpu")
164
+
165
+ # Extract state_dict (checkpoints have nested structure)
166
+ if isinstance(checkpoint, dict) and 'state_dict' in checkpoint:
167
+ state_dict = checkpoint['state_dict']
168
+ else:
169
+ state_dict = checkpoint
170
+
171
+ model.load_state_dict(state_dict)
172
+ model.eval()
173
+ ```
174
+
175
+ ## Architecture Description
176
+
177
+ This project uses two architectures:
178
+
179
+ 1. **SSLHead** - Self-supervised pretraining model built on a 3D Swin Transformer encoder
180
+ 2. **SwinUNETR** - Supervised segmentation model for downstream tasks
181
+
182
+ ### SSLHead (Pretraining Model)
183
+
184
+ The SSL pretraining model is a 3D SwinViT encoder equipped with self-supervised learning heads for **rotation prediction** and **contrastive representation learning**, as well as a VAE-style trilinear decoder for volume reconstruction.
185
+
186
+ **Key components:**
187
+
188
+ - **Backbone**: 3D Swin Transformer (`SwinViT` from MONAI)
189
+ - Patch size: `[2,2,2]`
190
+ - Window size: `[7,7,7]`
191
+ - Embedding dimension: 48
192
+ - Depths: `[2,2,2,2]`
193
+ - Number of heads: `[3,6,12,24]`
194
+ - **Bottleneck dimension**: 768
195
+ - **Self-supervised heads**:
196
+ - Rotation prediction: `nn.Linear(768, 4)`
197
+ - Contrastive learning: `nn.Linear(768, 512)`
198
+ - **Reconstruction decoder**: 5-stage upsampling with 3D convolutions + InstanceNorm + LeakyReLU (trilinear interpolation)
199
+
200
+ The SSLHead combines three self-supervised learning objectives in equal proportion:
201
+ - **Reconstruction loss**: VAE-style image reconstruction
202
+ - **Rotation prediction**: 4-way rotation classification
203
+ - **Contrastive loss**: Feature representation learning
204
+
205
+ See [SSL_Head.py](SSL_Head.py) for the complete implementation.
206
+
207
+ ### SwinUNETR (Finetuning Model)
208
+
209
+ The finetuning model uses MONAI's 3D **SwinUNETR**, which integrates a Swin Transformer encoder with a U-Net-style hierarchical decoder for dense segmentation tasks.
210
+
211
+ **Key components:**
212
+ - Patch-based 3D Swin Transformer encoder
213
+ - U-Net-style symmetric decoder with skip connections
214
+ - Depths: `[2,2,2,2]`
215
+ - Number of heads: `[3,6,12,24]`
216
+ - Input image size: `(96, 96, 96)`
217
+ - Output channels: 3 (task-dependent segmentation classes)
218
+
219
+ Both architectures are implemented using **MONAI** (commit `a23c7f54`).
220
+
221
+ ## Training Data
222
+
223
+ ### UK Biobank (Pretraining)
224
+
225
+ - **Subjects**: ~41,000
226
+ - **Data fields**: 20252 (T1-weighted MRI), 20253 (T2-weighted MRI)
227
+ - **Preprocessing**: Standard MONAI transforms (resizing and normalization)
228
+ - **Used in**: `model_weights_UKB-pretrain.pt`
229
+
230
+ ### BraTS (Pretraining and Finetuning)
231
+
232
+ - **Subjects**: 1,470
233
+ - **Task**: Brain tumor segmentation
234
+ - **Modalities**: Multi-modal 3D MRI
235
+ - **Preprocessing**: Standard normalization and cropping
236
+ - **Used in**: `model_weights_BRATS-pretrain.pt`, `model_weights_BRATS-finetune.pt`
237
+
238
+ ### ATLAS v2.0 (Pretraining and Finetuning)
239
+
240
+ - **Subjects**: 1,271
241
+ - **Task**: Stroke lesion segmentation
242
+ - **Preprocessing**: Standard MONAI transforms
243
+ - **Used in**: `model_weights_ATLAS-pretrain.pt`, `model_weights_ATLAS-finetune.pt`
244
+
245
+ ## Citation
246
+
247
+ If you use these model weights, please cite:
248
+
249
+ ```bibtex
250
+ @article{brainsegfounder2024,
251
+ title={BrainSegFounder: Self-supervised Learning for Brain MRI Segmentation},
252
+ journal={Medical Image Analysis},
253
+ year={2024},
254
+ doi={10.1016/j.media.2024.103301},
255
+ url={https://doi.org/10.1016/j.media.2024.103301}
256
+ }
257
+ ```
258
+
259
+ ## Privacy and Data Protection Statement
260
+
261
+ The returned model parameters do **not** contain any UK Biobank participant-level data, do not embed identifiable features, and cannot be used to reconstruct or infer individual-level MRI volumes.
262
+
263
+ The models store only aggregated statistical representations learned across tens of thousands of participants. They do not contain per-participant embeddings, IDs, or reconstructed images.
264
+
265
+ This submission complies with the UK Biobank requirement that *any parameters derived from UKB data be returned as derived variables*, while ensuring that no participant-level data or re-identifiable elements are included.
266
+
267
+ ## License and Allowed Use
268
+
269
+ These derived variables (model weights) may be accessed by future approved UK Biobank researchers under UK Biobank's standard access procedures.
270
+
271
+ The model architectures and research software used to train these models remain the intellectual property of the submitting researcher. The learned parameters, however, are derived from UK Biobank data and are therefore returned in accordance with:
272
+ - The UK Biobank Material Transfer Agreement (MTA)
273
+ - The UK Biobank "Use of Artificial Intelligence Applications and Models" policy
274
+
275
+ **License**: The model weights are subject to the [UK Biobank Material Transfer Agreement](https://www.ukbiobank.ac.uk/media/p3el3p0f/mta-v20-final-29mar2021-clean.pdf).
276
+
277
+ ## Contact
278
+
279
+ For questions about these models or collaborations, please open an issue in this repository or contact the authors through the paper.