Skip to content

Instantly share code, notes, and snippets.

View rherrick's full-sized avatar

Rick Herrick rherrick

  • Flywheel
  • St. Louis, Missouri
View GitHub Profile
@rherrick
rherrick / ConfigServiceConfiguration.java
Created June 4, 2014 16:39
Start-up errors with @configuration class without setBeanFactory() method
package org.nrg.xnat.bootstrap.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Arrays;
import java.util.List;
@Configuration
public class ConfigServiceConfiguration {
@rherrick
rherrick / dicom-import-context.xml
Created June 10, 2014 17:06
DICOM import context for mapping AE titles to separate projects
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<context:property-placeholder location="WEB-INF/conf/services.properties,WEB-INF/conf/services-custom.properties" ignore-resource-not-found="true" ignore-unresolvable="true"/>
<bean name="projectIdent1" class="org.nrg.dcm.id.FixedDicomProjectIdentifier">
<constructor-arg value="project1"/>
@rherrick
rherrick / GrabHttpBuilder0.7.2.log
Created June 30, 2014 18:38
Error encountered when I try to grab HTTP builder 0.7.2: @grab(group = 'org.codehaus.groovy.modules.http-builder', module = 'http-builder', version = '0.7.2')
1:36:15 PM 0 Grape dependency jars added
@Grab(group = 'org.codehaus.groovy.modules.http-builder', module = 'http-builder', version = '0.7.2'): 0 jars
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during conversion: No such property: canonicalPath for class: java.net.URL
groovy.lang.MissingPropertyException: No such property: canonicalPath for class: java.net.URL
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:63)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
at groovy.grape.GrapeIvy.(GrapeIvy.groovy:96)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
@rherrick
rherrick / GetRandomSubjectRestlet.java
Created July 23, 2014 16:49
Demonstrates the difference between getting a subject with user or null
/*
* org.nrg.xnat.restlet.extensions.GetRandomSubjectRestlet
* TIP is developed by the Neuroinformatics Research Group
* XNAT http://www.xnat.org
* Copyright (c) 2014, Washington University School of Medicine
* All Rights Reserved
*
* Released under the Simplified BSD.
*
* Last modified 7/22/14 9:24 AM
@rherrick
rherrick / makeUserAdmin.sql
Created September 18, 2014 14:50
Makes an XNAT user an admin. This requires the user to log out and back in again.
insert into xdat_r_xdat_role_type_assign_xdat_user (xdat_user_xdat_user_id,xdat_role_type_role_name) values ((select xdat_user_id from xdat_user where login = '$USER$'),'Administrator');
delete from xs_item_cache where contents like '%$USER$%';
@rherrick
rherrick / splitPetMrSessionSite.json
Last active August 29, 2015 14:07
Site-wide split PET-MR session configuration. This should only be used to test fail-over for sessions going to projects without project-specific scripts, since it adds a big "PSYCH-" prefix to the session name, which is silly.
{
"event": "dicomImport",
"content": "import org.dcm4che2.data.Tag\n\nlogger.info(\"Now running the site-wide splitPetMrSession script, I was passed ${defaultValue}\")\ndef sopClassUID = dicom.getString(Tag.SOPClassUID)\ndef modality = dicom.getString(Tag.Modality)\ndef seriesDescription = dicom.getString(Tag.SeriesDescription)\ndef isPet = \"PT\".equals(modality) || (\"1.3.12.2.1107.5.9.1\".equals(sopClassUID) && \"PET Start\".equals(seriesDescription))\nlogger.info(\"Found sopClassUID: ${sopClassUID}\")\nlogger.info(\"Found modality: ${modality}\")\nlogger.info(\"Found seriesDescription: ${seriesDescription}\")\nlogger.info(\"Found isPet: ${isPet}\")\ndef returnValue = \"PSYCH-${defaultValue}\"\nlogger.info(\"Result: ${returnValue} (cause I'm not actually doing much)\")\n\"${returnValue}\"\n",
"language": "groovy",
"languageVersion": "2.3.6"
}
@rherrick
rherrick / splitPetMrSessionProject1.json
Last active August 29, 2015 14:07
This actually splits the session into PET and MR sessions.
{
"event": "dicomImport",
"content": "import org.dcm4che2.data.Tag\n\nlogger.info(\"Now running the splitPetMrSession script for project ${projectId}, I was passed ${defaultValue}\")\ndef sopClassUID = dicom.getString(Tag.SOPClassUID)\ndef modality = dicom.getString(Tag.Modality)\ndef seriesDescription = dicom.getString(Tag.SeriesDescription)\ndef isPet = \"PT\".equals(modality) || (\"1.3.12.2.1107.5.9.1\".equals(sopClassUID) && \"PET Start\".equals(seriesDescription))\nlogger.info(\"Found sopClassUID: ${sopClassUID}\")\nlogger.info(\"Found modality: ${modality}\")\nlogger.info(\"Found seriesDescription: ${seriesDescription}\")\nlogger.info(\"Found isPet: ${isPet}\")\ndef returnValue = isPet ? defaultValue.reverse().replaceFirst(\"RM\", \"TEP\").reverse() : defaultValue\nlogger.info(\"Result: ${returnValue}\")\n\"${returnValue}\"\n",
"language": "groovy",
"languageVersion": "2.3.6"
}
@rherrick
rherrick / foo.xsd
Created October 7, 2014 17:11
Describes a possible solution for a user work list associated with a particular subject
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://foo.edu/schemas"
xmlns:foo="http://foo.edu/schemas"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xnat="http://nrg.wustl.edu/xnat"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:import namespace="http://nrg.wustl.edu/xnat" schemaLocation="../xnat/xnat.xsd"/>
import org.dcm4che2.data.Tag
logger.info("Now running the splitPetMrSession script for project ${projectId}, I was passed ${defaultValue}")
def sopClassUID = dicom.getString(Tag.SOPClassUID)
def modality = dicom.getString(Tag.Modality)
def seriesDescription = dicom.getString(Tag.SeriesDescription)
def isPet = "PT".equals(modality) || ("1.3.12.2.1107.5.9.1".equals(sopClassUID) && "PET Start".equals(seriesDescription))
logger.info("Found sopClassUID: ${sopClassUID}")
logger.info("Found modality: ${modality}")
logger.info("Found seriesDescription: ${seriesDescription}")
@rherrick
rherrick / javaAliases.sh
Last active August 29, 2015 14:08
Switch between Java 7 and 8 in bash
alias setJava7="$(set | fgrep -i jdk | sed 's/1.8.0_25/1.7.0_71/g' | sed 's/^/export /')"
alias setJava8="$(set | fgrep -i jdk | sed 's/1.7.0_71/1.8.0_25/g' | sed 's/^/export /')"