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 / create_recon.sh
Last active July 24, 2017 17:09
Create XNAT image reconstruction then update to include manually added files
# Get a session
http --auth admin:minda --session=admin xnat164.xnat.org/data/projects
# Create the reconstruction and resource folder
http --session=admin PUT xnat164.xnat.org/data/archive/projects/prj001/subjects/prj001_001/experiments/prj001_001_MR2/reconstructions/prj001_001_MR2_recon_001 xnat:reconstructedImageData/type==RECON_A
http --session=admin PUT xnat164.xnat.org/data/archive/projects/prj001/subjects/prj001_001/experiments/prj001_001_MR2/reconstructions/prj001_001_MR2_recon_001/resources/NIFTI format==NIFTI
# Upload NIFTI and JSON to the reconstruction resource
for SERIES in t1_mpr_1mm_p2_pos50_20061214091206_4 t1_mpr_1mm_p2_pos50_20061214091206_5 t2_spc_1mm_p2_20061214091206_6; do
http --session=admin PUT xnat164.xnat.org/data/archive/projects/prj001/subjects/prj001_001/experiments/prj001_001_MR2/reconstructions/prj001_001_MR2_recon_001/resources/NIFTI/files/${SERIES}.nii.gz inbody==true < ${SERIES}.nii.gz
@rherrick
rherrick / drop_xnat_views.sql
Created January 24, 2017 23:02
Find and Drop XNAT views
-- Change 'xnat' to the database user that owns the XNAT tables.
-- You need to stop Tomcat before running this query.
SELECT drop_user_views('xnat');
@rherrick
rherrick / xnatimport.log
Created September 5, 2016 23:16
Shows xnatimport execution and output on sample data
dpham@ipg-radiology:~$ xnatimport http://cnrmimages.ninds.nih.gov radiologics /data/cnrmimages/images/test Test
Setting work folder to /home/dpham/xnat/20160905191242.
radiologics is sending data for subject in /data/cnrmimages/images/test to project Test on the server http://cnrmimages.ninds.nih.gov
Enter host password for user 'radiologics':
Found session SUBJECT_02_MR03 in folder /data/cnrmimages/images/test/SUBJECT_02
Committing session to /data/prearchive/projects/Test/20160905_191248631/SUBJECT_02_MR03
Found session SUBJECT_02_MR02 in folder /data/cnrmimages/images/test/SUBJECT_02
Committing session to /data/prearchive/projects/Test/20160905_191259072/SUBJECT_02_MR02
Found session SUBJECT_02_MR01 in folder /data/cnrmimages/images/test/SUBJECT_02
Committing session to /data/prearchive/projects/Test/20160905_191310101/SUBJECT_02_MR01
@rherrick
rherrick / xterm.hex
Created September 3, 2016 19:19
Capture of ssh prompt weirdness and hex dump
00000000: 7573 6572 6e61 6d65 4077 6f72 6b73 7461 username@worksta
00000010: 7469 6f6e 207e 2024 2073 7368 2073 6572 tion ~ $ ssh ser
00000020: 7665 720a 4c61 7374 206c 6f67 696e 3a20 ver.Last login:
00000030: 5361 7420 5365 7020 2033 2031 343a 3034 Sat Sep 3 14:04
00000040: 3a30 3820 3230 3136 2066 726f 6d20 3130 :08 2016 from 10
00000050: 2e32 302e 3530 2e38 380a 0a1b 5d31 3333 .20.50.88...]133
00000060: 373b 5265 6d6f 7465 486f 7374 3d75 7365 7;RemoteHost=use
00000070: 726e 616d 6540 7365 7276 6572 2e68 6f73 rname@server.hos
00000080: 742e 6564 751b 5d31 3333 373b 4375 7272 t.edu.]1337;Curr
00000090: 656e 7444 6972 3d2f 686f 6d65 2f75 7365 entDir=/home/use
@rherrick
rherrick / display.xml
Created June 14, 2016 14:41
WORKSHOP_BIOSAMPLECOLLECTION_PROJECT_IDENTIFIER
<DisplayField id="WORKSHOP_BIOSAMPLECOLLECTION_PROJECT_IDENTIFIER" header="WORKSHOP_BIOSAMPLECOLLECTION ID" visible="true" searchable="false" data-type="string" xsi:type="SubQueryField">
<Content type="sql">workshop_biosamplecollection_project_id</Content>
<HTML-Link>
<SecureLink elementName="workshop:biosampleCollection">
<securityMappingValue displayFieldId="PROJECTS" schemaElementMap="workshop:biosampleCollection/sharing/share/project"/>
<securityMappingValue displayFieldId="PROJECT" schemaElementMap="workshop:biosampleCollection/project"/>
</SecureLink>
<Property name="HREF" value="@WEBAPPapp/action/DisplayItemAction/search_value/@Field1/search_element/workshop:biosampleCollection/search_field/workshop:biosampleCollection.ID/project/@Field2">
<InsertValue id="Field1" field="EXPT_ID"/>
<InsertValue id="Field2" field="@WHERE"/>
@rherrick
rherrick / dev_reset.sh
Created April 29, 2016 18:03
Server reset script for the xnatdev dev/test servers
# Shut down Tomcat if it's running.
[[ $(sudo service tomcat7 status) == *running* ]] && { echo Tomcat 7 is running, shutting it down.; sudo service tomcat7 stop; } || { echo Tomcat 7 is not running.; }
# Sleep for a couple seconds just to make sure it's done.
sleep 2
# Clear the database and recreate it.
psql -lqt | cut -d \| -f 1 | grep -qw xnatdev
[[ $? == 0 ]] && { echo Dropping existing database xnatdev...; dropdb xnatdev; } || { echo Database xnatdev does not exist.; }
echo Creating new empty database xnatdev.
@rherrick
rherrick / transfer.py
Created March 21, 2016 19:36
Creates new NIFTI resource folder at scan level, retrieves resource ID, and transfers an nii.gz file into the resource folder.
import requests
def get_nifti_resource_id(json):
result_set = json['ResultSet']
if result_set is None:
return
result = result_set['Result']
if result is None:
@rherrick
rherrick / nginx.log
Created February 5, 2016 20:37
Log entries from nginx and DNSQuestion attack
Feb 04, 2016 7:35:50 PM javax.jmdns.impl.constants.DNSRecordClass classForIndex
WARNING: Could not find record class for index: -1
Feb 04, 2016 7:35:50 PM javax.jmdns.impl.DNSIncoming$MessageInputStream readName
SEVERE: bad domain name: possible circular name detected. Bad offset: 0xffffffff at 0x2d
Feb 04, 2016 7:35:50 PM javax.jmdns.impl.constants.DNSRecordType typeForIndex
SEVERE: Could not find record type for index: -1
Feb 04, 2016 7:35:50 PM javax.jmdns.impl.DNSIncoming readQuestion
SEVERE: Could not find record type: dns[query,158.255.6.220:36002, length=47, id=0x0, questions=10990
questions:
[DNSQuestion@1096711572 type: TYPE_IGNORE index 0, class: CLASS_UNKNOWN index 0, name: ]
@rherrick
rherrick / exports
Last active December 7, 2015 20:27
Export configuration for VM sharing in /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
@rherrick
rherrick / get_jars.sh
Last active September 10, 2015 15:37
index.jsp and web.xml for modern skin
#!/bin/bash
# If you're on Ubuntu/Debian or a different version of Tomcat, you'll need to change this path.
cd /usr/share/tomcat6/webapps/xnat/WEB-INF/lib
wget -O standard-1.1.2.jar http://search.maven.org/remotecontent?filepath=taglibs/standard/1.1.2/standard-1.1.2.jar
wget -O jstl-1.2.jar http://search.maven.org/remotecontent?filepath=javax/servlet/jstl/1.2/jstl-1.2.jar