-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 13b9c43
Showing
14 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea/ | ||
*.pyc |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
|
||
class DataSet(object): | ||
def __init__(self, subjects=None): | ||
self.subjects = [] | ||
if subjects: | ||
for subject in subjects: | ||
self.add_subject(subject) | ||
|
||
def add_subject(self, subject): | ||
if subject.get_id() not in self.list_subject_ids(): | ||
self.subjects.append(subject) | ||
else: | ||
raise(ValueError("Duplicate subject subject_id found.")) | ||
|
||
def list_subject_ids(self): | ||
return [subject.get_id() for subject in self.subjects] | ||
|
||
def get_number_of_subjects(self): | ||
return len(self.subjects) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
|
||
class Group(object): | ||
def __init__(self): | ||
self._images = [] | ||
|
||
def add_image(self, image): | ||
self._images.append(image) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Image(object): | ||
def __init__(self, file_path=None, side_car_path=None): | ||
self.file_path = file_path | ||
self.side_car_path = side_car_path | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
|
||
class Session(object): | ||
def __init__(self): | ||
self._groups = [] | ||
|
||
def add_group(self, group): | ||
self._groups.append(group) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
|
||
class Subject(object): | ||
def __init__(self, subject_id=None): | ||
self.subject_id = subject_id | ||
self.sessions = [] | ||
|
||
def add_session(self, session): | ||
self.sessions.append(session) | ||
|
||
def get_id(self): | ||
return self.subject_id |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import unittest | ||
from unittest import TestCase | ||
from ..base.dataset import DataSet | ||
from ..base.subject import Subject | ||
|
||
|
||
class TestDataSet(TestCase): | ||
def test_add_subject(self): | ||
dataset = DataSet() | ||
dataset.add_subject(Subject()) | ||
|
||
def test_number_of_subjects(self): | ||
dataset = DataSet(subjects=[Subject("001"), Subject("002")]) | ||
self.assertEqual(dataset.get_number_of_subjects(), 2) | ||
|
||
def test_enforce_unique_ids(self): | ||
dataset = DataSet() | ||
subject_1 = Subject("001") | ||
dataset.add_subject(subject_1) | ||
subject_2 = Subject("001") | ||
with self.assertRaises(ValueError): | ||
dataset.add_subject(subject_2) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import unittest | ||
from unittest import TestCase | ||
from bids.base.group import Group | ||
from bids.base.image import Image | ||
|
||
|
||
class TestGroup(TestCase): | ||
def setUp(self): | ||
self.group = Group() | ||
|
||
def test_add_image(self): | ||
image = Image() | ||
self.group.add_image(image) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from unittest import TestCase | ||
|
||
|
||
class TestImage(TestCase): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import unittest | ||
from unittest import TestCase | ||
from ..base.session import Session | ||
from ..base.group import Group | ||
|
||
|
||
class TestSession(TestCase): | ||
|
||
def test_add_group(self): | ||
session = Session() | ||
session.add_group(Group()) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import unittest | ||
from unittest import TestCase | ||
from ..base.session import Session | ||
from ..base.subject import Subject | ||
|
||
|
||
class TestSubject(TestCase): | ||
def test_add_session(self): | ||
subject = Subject() | ||
subject.add_session(Session()) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |