Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIMS 1.1 #106

Merged
merged 5 commits into from
Jan 5, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
adapt nims1 to use nimsdata2
  • Loading branch information
kevlarkevin committed Jan 5, 2015
commit 537e841664a263f55987bdb7862eed1952b23dc9
20 changes: 6 additions & 14 deletions apache.conf
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
WSGIDaemonProcess nims processes=4 threads=16 maximum-requests=1000 display-name=%{GROUP}
WSGIDaemonProcess nims user=nims group=nims processes=2 threads=4 maximum-requests=1000 display-name=%(GROUP)

<Directory /var/local/nims>
WSGIApplicationGroup %{GLOBAL}
WSGIProcessGroup nims
</Directory>

Redirect /nimsgears /nims
WSGIScriptAlias /nims /var/local/nims/nimsgears/public/nims.wsgi
WSGIScriptAlias /nims /var/local/nims/nimsgears/public/nims.wsgi

Alias /nims/images /var/local/nims/nimsgears/public/images
Alias /nims/css /var/local/nims/nimsgears/public/css
Alias /nims/javascript /var/local/nims/nimsgears/public/javascript
Alias /nims/static /var/local/nims/nimsgears/public/static
Alias /nims/images /var/local/nims/nimsgears/public/images
Alias /nims/css /var/local/nims/nimsgears/public/css
Alias /nims/javascript /var/local/nims/nimsgears/public/javascript

<IfModule mime_module>
AddType application/octet-stream .7 .bvec .bval .dcm .dat
</IfModule>

<Directory /run/shm/nimslinks>
Order allow,deny
Allow from all
Options Indexes FollowSymLinks
AllowOverride AuthConfig
</Directory>

<Location /nims/auth>
AuthType WebAuth
Require valid-user
Expand Down
2 changes: 1 addition & 1 deletion nimsdata
6 changes: 3 additions & 3 deletions nimsgears/controllers/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from tg.i18n import ugettext as _, lazy_ugettext as l_
import webob.exc

import nimsdata
import nimsdata.medimg.nimsmontage
import nimsutil
from nimsgears.model import *

Expand Down Expand Up @@ -89,7 +89,7 @@ def pyramid(self, **kwargs):
ds = Dataset.get(kwargs['dataset_id'])
if user.has_access_to(ds):
db_file = os.path.join(store_path, ds.relpath, ds.filenames[0])
return dict(zip(['dataset_id', 'tile_size', 'x_size', 'y_size'], (ds.id,) + nimsdata.nimsmontage.get_info(db_file)))
return dict(zip(['dataset_id', 'tile_size', 'x_size', 'y_size'], (ds.id,) + nimsdata.medimg.nimsmontage.get_info(db_file)))

@expose('nimsgears.templates.qa_report', render_params={'doctype': None})
def qa_report(self, **kwargs):
Expand Down Expand Up @@ -156,7 +156,7 @@ def pyramid_tile(self, *args):
response.etag = args[0]
response.cache_control = 'max-age = 86400'
response.last_modified = ds.updatetime
return nimsdata.nimsmontage.get_tile(os.path.join(store_path, ds.relpath, ds.filenames[0]), z, x, y)
return nimsdata.medimg.nimsmontage.get_tile(os.path.join(store_path, ds.relpath, ds.filenames[0]), z, x, y)

@expose(content_type='application/octet-stream')
def file(self, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions nimsgears/controllers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy
import datetime

import nimsdata
import nimsdata.medimg.dcm.mr.generic_mr
from nimsgears.model import *
from nimsgears.controllers.nims import NimsController

Expand Down Expand Up @@ -97,7 +97,7 @@ def index(self):
epoch_columns = [('Group', 'col_sunet'), ('Experiment', 'col_exp'), ('Date & Time', 'col_datetime'),
('Exam', 'col_exam'), ('Type Scan', 'col_scantype'), ('Description', 'col_desc')]
dataset_columns = [('Data Type', 'col_type')]
scantype_values = [''] + sorted(nimsdata.nimsmrdata.scan_types.all)
scantype_values = [''] + sorted(nimsdata.medimg.dcm.mr.generic_mr.scan_types.all)
psd_names_tuples = DBSession.query(Epoch.psd).distinct(Epoch.psd)
psd_values = [''] + sorted([elem[0] for elem in psd_names_tuples])
return dict(page='search',
Expand Down
22 changes: 11 additions & 11 deletions nimsgears/model/nims.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def __unicode__(self):
class Job(Entity):

timestamp = Field(DateTime, default=datetime.datetime.now)
status = Field(Enum(u'pending', u'running', u'done', u'failed', u'abandoned', name=u'job_status'))
status = Field(Enum(u'pending', u'running', u'done', u'failed', u'abandoned', 'rerun', name=u'job_status'))
task = Field(Enum(u'find', u'proc', u'find&proc', name=u'job_task'))
needs_rerun = Field(Boolean, default=False)
progress = Field(Integer)
Expand Down Expand Up @@ -509,13 +509,13 @@ def __unicode__(self):

@classmethod
def from_mrfile(cls, mrfile):
subj_code, group_name, exp_name = nimsutil.parse_patient_id(mrfile.patient_id, ResearchGroup.all_ids())
subj_code, group_name, exp_name = nimsutil.parse_patient_id__(mrfile.subj_code, mrfile.group_name, mrfile.project_name, ResearchGroup.all_ids())
query = cls.query.join(Experiment, cls.experiment).filter(Experiment.name == exp_name)
query = query.join(ResearchGroup, Experiment.owner).filter(ResearchGroup.gid == group_name)
if subj_code:
subject = query.filter(cls.code==subj_code).first()
elif mrfile.subj_firstname and mrfile.subj_lastname:
subject = query.filter(cls.firstname==mrfile.subj_firstname).filter(cls.lastname==mrfile.subj_lastname).filter(cls.dob==mrfile.subj_dob).first()
subject = query.filter(cls.firstname==unicode(mrfile.subj_firstname)).filter(cls.lastname==unicode(mrfile.subj_lastname)).filter(cls.dob==mrfile.subj_dob).first()
else:
subject = None
if not subject:
Expand All @@ -525,8 +525,8 @@ def from_mrfile(cls, mrfile):
experiment=experiment,
person=Person(),
code=subj_code[:31] or experiment.next_subject_code,
firstname=mrfile.subj_firstname[:63],
lastname=mrfile.subj_lastname[:63],
firstname=(unicode(mrfile.subj_firstname) or u'')[:63],
lastname=(unicode(mrfile.subj_lastname) or u'')[:63],
dob=mrfile.subj_dob,
)
return subject
Expand Down Expand Up @@ -605,7 +605,7 @@ def from_mrfile(cls, mrfile):
# central authority and/or querying the schedule database. But for now,
# just let the operator be None if the user isn't already in the system.
operator = User.by_uid(unicode(mrfile.operator), create=False)
session = Session(uid=uid, exam=mrfile.exam_no, subject=subject, operator=operator)
session = Session(uid=uid, exam=mrfile.exam_no if isinstance(mrfile.exam_no, int) else 0, subject=subject, operator=operator)
return session

@classmethod
Expand Down Expand Up @@ -708,13 +708,13 @@ def from_mrfile(cls, mrfile):
epoch = cls.query.filter_by(uid=uid).filter_by(acq=mrfile.acq_no).first()
if not epoch:
session = Session.from_mrfile(mrfile)
if session.timestamp is None or session.timestamp > mrfile.timestamp:
if session.timestamp is None or (mrfile.timestamp is not None and session.timestamp > mrfile.timestamp):
session.timestamp = mrfile.timestamp
epoch = cls(
session = session,
timestamp = mrfile.timestamp,
duration = datetime.timedelta(0, mrfile.duration),
prescribed_duration = datetime.timedelta(0, mrfile.prescribed_duration),
duration = datetime.timedelta(0, mrfile.duration or 0),
prescribed_duration = datetime.timedelta(0, mrfile.prescribed_duration or 0),
uid = uid,
series = mrfile.series_no,
acq = mrfile.acq_no,
Expand Down Expand Up @@ -758,11 +758,11 @@ def toplevel_query(cls):

@property
def name(self):
return '%d_%d_%d' % (self.session.exam, self.series, self.acq)
return '%d_%d%s' % (self.session.exam, self.series, '_%d' % self.acq if self.acq is not None else '')

@property
def dirname(self):
return '%d_%d_%s' % (self.series, self.acq, self.description)
return '%d%s_%s' % (self.series, '_%d' % self.acq if self.acq is not None else '', self.description)

@property
def contains_trash(self):
Expand Down
Loading