File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 99import glob
1010from typing import Literal , Optional
1111from openlifu .plan import Protocol , Solution
12- from openlifu .db import Subject
12+ from openlifu .db import Subject , Session
1313OnConflictOpts = Literal ['error' , 'overwrite' , 'skip' ]
1414
1515
@@ -425,7 +425,6 @@ def load_all_protocols(self):
425425 raise FileNotFoundError ("Protocols file not found." )
426426
427427 def load_session (self , subject , session_id , options = None ):
428- raise NotImplementedError ("Session.from_file is not yet implemented" )
429428 if options is None :
430429 options = {}
431430 session_filename = self .get_session_filename (subject .id , session_id )
Original file line number Diff line number Diff line change 55from openlifu .xdc import Transducer
66from openlifu .util .strings import sanitize
77import xarray
8+ import json
89
910@dataclass
1011class Session :
@@ -49,6 +50,17 @@ def __post_init__(self):
4950 else :
5051 self .markers = list (self .markers )
5152
53+ @staticmethod
54+ def from_file (filename ):
55+ """
56+ Create a Session from a file
57+
58+ :param filename: Name of the file to read
59+ :returns: Session object
60+ """
61+ with open (filename , 'r' ) as f :
62+ return Session .from_dict (json .load (f ))
63+
5264 @staticmethod
5365 def from_dict (d ):
5466 """
You can’t perform that action at this time.
0 commit comments