Skip to content

Commit b321c59

Browse files
committed
Merge branch 'meg-ctf-head-files-orm-models' into HEAD
2 parents 8ce20c4 + eb5f45a commit b321c59

3 files changed

Lines changed: 100 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from pathlib import Path
2+
3+
from sqlalchemy.orm import Mapped, mapped_column, relationship
4+
5+
import lib.db.models.meg_ctf_head_shape_point as db_meg_ctf_head_shape_point
6+
from lib.db.base import Base
7+
from lib.db.decorators.string_path import StringPath
8+
9+
10+
class DbMegCtfHeadShapeFile(Base):
11+
"""
12+
A MEG CTF `headshape.pos` file. This file contains 3D points positioned on the subject head and
13+
is shared by all the CTF files of an MEG acquisition.
14+
"""
15+
16+
__tablename__ = 'meg_ctf_head_shape_file'
17+
18+
id: Mapped[int] = mapped_column('ID', primary_key=True)
19+
"""
20+
ID of the head shape file.
21+
"""
22+
23+
path: Mapped[Path] = mapped_column('Path', StringPath)
24+
"""
25+
Path of the head shape file relative to the LORIS data directory.
26+
"""
27+
28+
blake2b_hash: Mapped[str] = mapped_column('Blake2bHash')
29+
"""
30+
Blake2B hash of the head shape file, which may be used to check that the on-disk file data
31+
matches the file registered in the LORIS database.
32+
"""
33+
34+
points: Mapped[list['db_meg_ctf_head_shape_point.DbMegCtfHeadShapePoint']] = relationship('DbMegCtfHeadShapePoint', back_populates='file')
35+
"""
36+
3D points present in the head shape file.
37+
"""
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
from decimal import Decimal
2+
3+
from sqlalchemy import ForeignKey
4+
from sqlalchemy.orm import Mapped, mapped_column, relationship
5+
6+
import lib.db.models.meg_ctf_head_shape_file as db_meg_ctf_head_shape_file
7+
from lib.db.base import Base
8+
9+
10+
# TODO: It might be possible that headshape files contain points in other units than centimeters,
11+
# in which case the database should be extended to handle it.
12+
class DbMegCtfHeadShapePoint(Base):
13+
"""
14+
A 3D point present in a MEG CTF `headshape.pos` file.
15+
"""
16+
17+
__tablename__ = 'meg_ctf_head_shape_point'
18+
19+
id: Mapped[int] = mapped_column('ID', primary_key=True)
20+
"""
21+
ID of the head shape point.
22+
"""
23+
24+
file_id: Mapped[int] = mapped_column('FileID', ForeignKey('meg_ctf_head_shape_file.ID'))
25+
"""
26+
ID of the head shape file to which this point belongs.
27+
"""
28+
29+
name: Mapped[str] = mapped_column('Name')
30+
"""
31+
Name of the point, which may either be an integer or an anatomical landmark label.
32+
"""
33+
34+
x: Mapped[Decimal] = mapped_column('X')
35+
"""
36+
X coordinate of the point in the head shape file, in centimeters.
37+
"""
38+
39+
y: Mapped[Decimal] = mapped_column('Y')
40+
"""
41+
Y coordinate of the point in the head shape file, in centimeters.
42+
"""
43+
44+
z: Mapped[Decimal] = mapped_column('Z')
45+
"""
46+
Z coordinate of the point in the head shape file, in centimeters.
47+
"""
48+
49+
file: Mapped['db_meg_ctf_head_shape_file.DbMegCtfHeadShapeFile'] = relationship('DbMegCtfHeadShapeFile', back_populates='points')
50+
"""
51+
The head shape file to which this point belongs.
52+
"""

python/lib/db/models/physio_file.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from sqlalchemy import ForeignKey
55
from sqlalchemy.orm import Mapped, mapped_column, relationship
66

7+
import lib.db.models.meg_ctf_head_shape_file as db_meg_ctf_head_shape_file
78
import lib.db.models.physio_channel as db_physio_channel
89
import lib.db.models.physio_event_archive as db_physio_event_archive
910
import lib.db.models.physio_event_file as db_physio_event_file
@@ -42,6 +43,11 @@ class DbPhysioFile(Base):
4243
file or an archive. The path is relative to the LORIS data directory.
4344
"""
4445

46+
head_shape_file_id: Mapped[int | None] = mapped_column('HeadShapeFileID', ForeignKey('meg_ctf_head_shape_file.ID'))
47+
"""
48+
ID of the head shape file associated to this file, which is only present for MEG CTF files.
49+
"""
50+
4551
output_type : Mapped['db_physio_output_type.DbPhysioOutputType'] = relationship('DbPhysioOutputType')
4652
modality : Mapped['db_physio_modality.DbPhysioModality | None'] = relationship('DbPhysioModality')
4753
session : Mapped['db_session.DbSession'] = relationship('DbSession')
@@ -50,3 +56,8 @@ class DbPhysioFile(Base):
5056
channels : Mapped[list['db_physio_channel.DbPhysioChannel']] = relationship('DbPhysioChannel', back_populates='physio_file')
5157
parameters : Mapped[list['db_phyiso_file_parameter.DbPhysioFileParameter']] = relationship('DbPhysioFileParameter', back_populates='file')
5258
event_files : Mapped[list['db_physio_event_file.DbPhysioEventFile']] = relationship('DbPhysioEventFile', back_populates='physio_file')
59+
60+
head_shape_file: Mapped['db_meg_ctf_head_shape_file.DbMegCtfHeadShapeFile | None'] = relationship('DbMegCtfHeadShapeFile')
61+
"""
62+
The head shape file associated to this file, which is only present for MEG CTF files.
63+
"""

0 commit comments

Comments
 (0)