{"action":"created","comment":{"url":"https://api.github.com/repos/process-asl/process-asl/pulls/comments/53569672","id":53569672,"diff_hunk":"@@ -0,0 +1,123 @@\n+\"\"\"\n+=========================\n+One subject pipeline demo\n+=========================\n+\n+This example gives a basic single subject pipeline for computing CBF from\n+ASL data.\n+\"\"\"\n+# Give the path to the 4D ASL and anatomical images\n+import os\n+from procasl import datasets\n+heroes = datasets.load_heroes_dataset(\n+    subjects=(0,),\n+    subjects_parent_directory=os.path.join(\n+        os.path.expanduser('~/procasl_data'), 'heroes'),\n+    dataset_pattern={'anat': 't1mri/acquisition1/anat*.nii',\n+                     'basal ASL': 'fMRI/acquisition1/basal_rawASL*.nii'})\n+asl_file = heroes['basal ASL'][0]\n+anat_file = heroes['anat'][0]\n+\n+# Create a memory context\n+from nipype.caching import Memory\n+current_directory = os.getcwd()\n+cache_directory = '/tmp'\n+os.chdir(cache_directory)\n+mem = Memory(cache_directory)\n+\n+# Get Tag/Control sequence\n+from procasl import preprocessing\n+get_tag_ctl = mem.cache(preprocessing.RemoveFirstScanControl)\n+out_get_tag_ctl = get_tag_ctl(in_file=asl_file)\n+\n+# Rescale\n+rescale = mem.cache(preprocessing.Rescale)\n+out_rescale = rescale(in_file=out_get_tag_ctl.outputs.tag_ctl_file,\n+                      ss_tr=35.4, t_i_1=800., t_i_2=1800.)\n+\n+# Realign to first scan\n+realign = mem.cache(preprocessing.Realign)\n+out_realign = realign(\n+    in_file=out_rescale.outputs.rescaled_file,\n+    register_to_mean=False,\n+    correct_tagging=True)\n+\n+# Compute mean ASL\n+average = mem.cache(preprocessing.Average)\n+out_average = average(in_file=out_realign.outputs.realigned_files)\n+\n+# Segment anat\n+#import os\n+#spm_path = spm.Info.version()['path']\n+#tissue_prob_maps = [os.path.join(spm_path, 'tpm', filename) for filename in\n+#                    ['grey.nii', 'white.nii', 'csf.nii']]\n+import nipype.interfaces.spm as spm\n+segment = mem.cache(spm.Segment)\n+out_segment = segment(\n+    data=anat_file,\n+    gm_output_type=[False, False, True],\n+    wm_output_type=[False, False, True],\n+    save_bias_corrected=True)\n+\n+# Coregister anat to mean ASL\n+coregister_anat = mem.cache(spm.Coregister)\n+out_coregister_anat = coregister_anat(\n+    target=out_average.outputs.mean_image,\n+    source=anat_file,\n+    apply_to_files=[out_segment.outputs.native_gm_image,\n+                    out_segment.outputs.native_wm_image],\n+    write_interp=3,\n+    jobtype='estwrite')\n+\n+# Get M0\n+get_m0 = mem.cache(preprocessing.GetFirstScan)\n+out_get_m0 = get_m0(in_file=asl_file)\n+\n+# Coregister M0 to mean ASL\n+coregister_m0 = mem.cache(spm.Coregister)\n+out_coregister_m0 = coregister_m0(\n+    target=out_average.outputs.mean_image,\n+    source=out_get_m0.outputs.m0_file,\n+    write_interp=3,\n+    jobtype='estwrite')\n+\n+# Smooth M0\n+smooth_m0 = mem.cache(spm.Smooth)\n+out_smooth_m0 = smooth_m0(\n+    in_files=out_coregister_m0.outputs.coregistered_source,\n+    fwhm=[5., 5., 5.])\n+\n+# Compute perfusion\n+from procasl import preprocessing, quantification\n+n_scans = preprocessing.get_scans_number(out_realign.outputs.realigned_files)\n+ctl_scans = range(1, n_scans, 2)\n+tag_scans = range(0, n_scans, 2)\n+perfusion_file = quantification.compute_perfusion(\n+    out_realign.outputs.realigned_files,\n+    ctl_scans=ctl_scans,\n+    tag_scans=tag_scans)\n+\n+# Compute CBF\n+quantify = mem.cache(quantification.QuantifyCBF)\n+out_quantify = quantify(\n+    perfusion_file=perfusion_file,\n+    m0_file=out_smooth_m0.outputs.smoothed_files,\n+    tr=2500.,\n+    t1_gm=1331.)\n+\n+# Mask CBF map with brain mask\n+brain_mask_file = preprocessing.compute_brain_mask(\n+    out_coregister_anat.outputs.coregistered_source, frac=.2)\n+cbf_map = preprocessing.apply_mask(out_quantify.outputs.cbf_file,\n+                                   brain_mask_file)\n+\n+# Plot CBF map on top of anat\n+import matplotlib.pylab as plt","path":"examples/pipelines/single_subject.py","position":115,"original_position":115,"commit_id":"50d50fa2b8e2265dd177cd6d244890104f8a199a","original_commit_id":"50d50fa2b8e2265dd177cd6d244890104f8a199a","user":{"login":"salma1601","id":7080143,"avatar_url":"https://avatars.githubusercontent.com/u/7080143?v=3","gravatar_id":"","url":"https://api.github.com/users/salma1601","html_url":"https://github.com/salma1601","followers_url":"https://api.github.com/users/salma1601/followers","following_url":"https://api.github.com/users/salma1601/following{/other_user}","gists_url":"https://api.github.com/users/salma1601/gists{/gist_id}","starred_url":"https://api.github.com/users/salma1601/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/salma1601/subscriptions","organizations_url":"https://api.github.com/users/salma1601/orgs","repos_url":"https://api.github.com/users/salma1601/repos","events_url":"https://api.github.com/users/salma1601/events{/privacy}","received_events_url":"https://api.github.com/users/salma1601/received_events","type":"User","site_admin":false},"body":"compare to relCBF ?","created_at":"2016-02-21T17:18:17Z","updated_at":"2016-02-21T17:18:17Z","html_url":"https://github.com/process-asl/process-asl/pull/13#discussion_r53569672","pull_request_url":"https://api.github.com/repos/process-asl/process-asl/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/process-asl/process-asl/pulls/comments/53569672"},"html":{"href":"https://github.com/process-asl/process-asl/pull/13#discussion_r53569672"},"pull_request":{"href":"https://api.github.com/repos/process-asl/process-asl/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/process-asl/process-asl/pulls/13","id":60094450,"html_url":"https://github.com/process-asl/process-asl/pull/13","diff_url":"https://github.com/process-asl/process-asl/pull/13.diff","patch_url":"https://github.com/process-asl/process-asl/pull/13.patch","issue_url":"https://api.github.com/repos/process-asl/process-asl/issues/13","number":13,"state":"open","locked":false,"title":"adding basic examples","user":{"login":"salma1601","id":7080143,"avatar_url":"https://avatars.githubusercontent.com/u/7080143?v=3","gravatar_id":"","url":"https://api.github.com/users/salma1601","html_url":"https://github.com/salma1601","followers_url":"https://api.github.com/users/salma1601/followers","following_url":"https://api.github.com/users/salma1601/following{/other_user}","gists_url":"https://api.github.com/users/salma1601/gists{/gist_id}","starred_url":"https://api.github.com/users/salma1601/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/salma1601/subscriptions","organizations_url":"https://api.github.com/users/salma1601/orgs","repos_url":"https://api.github.com/users/salma1601/repos","events_url":"https://api.github.com/users/salma1601/events{/privacy}","received_events_url":"https://api.github.com/users/salma1601/received_events","type":"User","site_admin":false},"body":"basic examples to show pipeline caching and preprocessing steps","created_at":"2016-02-21T16:55:35Z","updated_at":"2016-02-21T17:18:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b923ed166ce96011ee1c3be248c33cd383147ecb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/process-asl/process-asl/pulls/13/commits","review_comments_url":"https://api.github.com/repos/process-asl/process-asl/pulls/13/comments","review_comment_url":"https://api.github.com/repos/process-asl/process-asl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/process-asl/process-asl/issues/13/comments","statuses_url":"https://api.github.com/repos/process-asl/process-asl/statuses/50d50fa2b8e2265dd177cd6d244890104f8a199a","head":{"label":"salma1601:basic_examples","ref":"basic_examples","sha":"50d50fa2b8e2265dd177cd6d244890104f8a199a","user":{"login":"salma1601","id":7080143,"avatar_url":"https://avatars.githubusercontent.com/u/7080143?v=3","gravatar_id":"","url":"https://api.github.com/users/salma1601","html_url":"https://github.com/salma1601","followers_url":"https://api.github.com/users/salma1601/followers","following_url":"https://api.github.com/users/salma1601/following{/other_user}","gists_url":"https://api.github.com/users/salma1601/gists{/gist_id}","starred_url":"https://api.github.com/users/salma1601/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/salma1601/subscriptions","organizations_url":"https://api.github.com/users/salma1601/orgs","repos_url":"https://api.github.com/users/salma1601/repos","events_url":"https://api.github.com/users/salma1601/events{/privacy}","received_events_url":"https://api.github.com/users/salma1601/received_events","type":"User","site_admin":false},"repo":{"id":52009128,"name":"process-asl","full_name":"salma1601/process-asl","owner":{"login":"salma1601","id":7080143,"avatar_url":"https://avatars.githubusercontent.com/u/7080143?v=3","gravatar_id":"","url":"https://api.github.com/users/salma1601","html_url":"https://github.com/salma1601","followers_url":"https://api.github.com/users/salma1601/followers","following_url":"https://api.github.com/users/salma1601/following{/other_user}","gists_url":"https://api.github.com/users/salma1601/gists{/gist_id}","starred_url":"https://api.github.com/users/salma1601/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/salma1601/subscriptions","organizations_url":"https://api.github.com/users/salma1601/orgs","repos_url":"https://api.github.com/users/salma1601/repos","events_url":"https://api.github.com/users/salma1601/events{/privacy}","received_events_url":"https://api.github.com/users/salma1601/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/salma1601/process-asl","description":"Arterial spin labeling data processing","fork":true,"url":"https://api.github.com/repos/salma1601/process-asl","forks_url":"https://api.github.com/repos/salma1601/process-asl/forks","keys_url":"https://api.github.com/repos/salma1601/process-asl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/salma1601/process-asl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/salma1601/process-asl/teams","hooks_url":"https://api.github.com/repos/salma1601/process-asl/hooks","issue_events_url":"https://api.github.com/repos/salma1601/process-asl/issues/events{/number}","events_url":"https://api.github.com/repos/salma1601/process-asl/events","assignees_url":"https://api.github.com/repos/salma1601/process-asl/assignees{/user}","branches_url":"https://api.github.com/repos/salma1601/process-asl/branches{/branch}","tags_url":"https://api.github.com/repos/salma1601/process-asl/tags","blobs_url":"https://api.github.com/repos/salma1601/process-asl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/salma1601/process-asl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/salma1601/process-asl/git/refs{/sha}","trees_url":"https://api.github.com/repos/salma1601/process-asl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/salma1601/process-asl/statuses/{sha}","languages_url":"https://api.github.com/repos/salma1601/process-asl/languages","stargazers_url":"https://api.github.com/repos/salma1601/process-asl/stargazers","contributors_url":"https://api.github.com/repos/salma1601/process-asl/contributors","subscribers_url":"https://api.github.com/repos/salma1601/process-asl/subscribers","subscription_url":"https://api.github.com/repos/salma1601/process-asl/subscription","commits_url":"https://api.github.com/repos/salma1601/process-asl/commits{/sha}","git_commits_url":"https://api.github.com/repos/salma1601/process-asl/git/commits{/sha}","comments_url":"https://api.github.com/repos/salma1601/process-asl/comments{/number}","issue_comment_url":"https://api.github.com/repos/salma1601/process-asl/issues/comments{/number}","contents_url":"https://api.github.com/repos/salma1601/process-asl/contents/{+path}","compare_url":"https://api.github.com/repos/salma1601/process-asl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/salma1601/process-asl/merges","archive_url":"https://api.github.com/repos/salma1601/process-asl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/salma1601/process-asl/downloads","issues_url":"https://api.github.com/repos/salma1601/process-asl/issues{/number}","pulls_url":"https://api.github.com/repos/salma1601/process-asl/pulls{/number}","milestones_url":"https://api.github.com/repos/salma1601/process-asl/milestones{/number}","notifications_url":"https://api.github.com/repos/salma1601/process-asl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/salma1601/process-asl/labels{/name}","releases_url":"https://api.github.com/repos/salma1601/process-asl/releases{/id}","deployments_url":"https://api.github.com/repos/salma1601/process-asl/deployments","created_at":"2016-02-18T13:30:15Z","updated_at":"2016-02-17T17:34:56Z","pushed_at":"2016-02-21T17:07:05Z","git_url":"git://github.com/salma1601/process-asl.git","ssh_url":"git@github.com:salma1601/process-asl.git","clone_url":"https://github.com/salma1601/process-asl.git","svn_url":"https://github.com/salma1601/process-asl","homepage":null,"size":36,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"process-asl:master","ref":"master","sha":"00edfe81ebaec31c33dc6fcf9f82a28deb123a16","user":{"login":"process-asl","id":17299310,"avatar_url":"https://avatars.githubusercontent.com/u/17299310?v=3","gravatar_id":"","url":"https://api.github.com/users/process-asl","html_url":"https://github.com/process-asl","followers_url":"https://api.github.com/users/process-asl/followers","following_url":"https://api.github.com/users/process-asl/following{/other_user}","gists_url":"https://api.github.com/users/process-asl/gists{/gist_id}","starred_url":"https://api.github.com/users/process-asl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/process-asl/subscriptions","organizations_url":"https://api.github.com/users/process-asl/orgs","repos_url":"https://api.github.com/users/process-asl/repos","events_url":"https://api.github.com/users/process-asl/events{/privacy}","received_events_url":"https://api.github.com/users/process-asl/received_events","type":"Organization","site_admin":false},"repo":{"id":51941642,"name":"process-asl","full_name":"process-asl/process-asl","owner":{"login":"process-asl","id":17299310,"avatar_url":"https://avatars.githubusercontent.com/u/17299310?v=3","gravatar_id":"","url":"https://api.github.com/users/process-asl","html_url":"https://github.com/process-asl","followers_url":"https://api.github.com/users/process-asl/followers","following_url":"https://api.github.com/users/process-asl/following{/other_user}","gists_url":"https://api.github.com/users/process-asl/gists{/gist_id}","starred_url":"https://api.github.com/users/process-asl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/process-asl/subscriptions","organizations_url":"https://api.github.com/users/process-asl/orgs","repos_url":"https://api.github.com/users/process-asl/repos","events_url":"https://api.github.com/users/process-asl/events{/privacy}","received_events_url":"https://api.github.com/users/process-asl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/process-asl/process-asl","description":"Arterial spin labeling data processing","fork":false,"url":"https://api.github.com/repos/process-asl/process-asl","forks_url":"https://api.github.com/repos/process-asl/process-asl/forks","keys_url":"https://api.github.com/repos/process-asl/process-asl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/process-asl/process-asl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/process-asl/process-asl/teams","hooks_url":"https://api.github.com/repos/process-asl/process-asl/hooks","issue_events_url":"https://api.github.com/repos/process-asl/process-asl/issues/events{/number}","events_url":"https://api.github.com/repos/process-asl/process-asl/events","assignees_url":"https://api.github.com/repos/process-asl/process-asl/assignees{/user}","branches_url":"https://api.github.com/repos/process-asl/process-asl/branches{/branch}","tags_url":"https://api.github.com/repos/process-asl/process-asl/tags","blobs_url":"https://api.github.com/repos/process-asl/process-asl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/process-asl/process-asl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/process-asl/process-asl/git/refs{/sha}","trees_url":"https://api.github.com/repos/process-asl/process-asl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/process-asl/process-asl/statuses/{sha}","languages_url":"https://api.github.com/repos/process-asl/process-asl/languages","stargazers_url":"https://api.github.com/repos/process-asl/process-asl/stargazers","contributors_url":"https://api.github.com/repos/process-asl/process-asl/contributors","subscribers_url":"https://api.github.com/repos/process-asl/process-asl/subscribers","subscription_url":"https://api.github.com/repos/process-asl/process-asl/subscription","commits_url":"https://api.github.com/repos/process-asl/process-asl/commits{/sha}","git_commits_url":"https://api.github.com/repos/process-asl/process-asl/git/commits{/sha}","comments_url":"https://api.github.com/repos/process-asl/process-asl/comments{/number}","issue_comment_url":"https://api.github.com/repos/process-asl/process-asl/issues/comments{/number}","contents_url":"https://api.github.com/repos/process-asl/process-asl/contents/{+path}","compare_url":"https://api.github.com/repos/process-asl/process-asl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/process-asl/process-asl/merges","archive_url":"https://api.github.com/repos/process-asl/process-asl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/process-asl/process-asl/downloads","issues_url":"https://api.github.com/repos/process-asl/process-asl/issues{/number}","pulls_url":"https://api.github.com/repos/process-asl/process-asl/pulls{/number}","milestones_url":"https://api.github.com/repos/process-asl/process-asl/milestones{/number}","notifications_url":"https://api.github.com/repos/process-asl/process-asl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/process-asl/process-asl/labels{/name}","releases_url":"https://api.github.com/repos/process-asl/process-asl/releases{/id}","deployments_url":"https://api.github.com/repos/process-asl/process-asl/deployments","created_at":"2016-02-17T17:34:56Z","updated_at":"2016-02-20T15:12:52Z","pushed_at":"2016-02-21T17:07:06Z","git_url":"git://github.com/process-asl/process-asl.git","ssh_url":"git@github.com:process-asl/process-asl.git","clone_url":"https://github.com/process-asl/process-asl.git","svn_url":"https://github.com/process-asl/process-asl","homepage":null,"size":30,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":10,"forks":1,"open_issues":10,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/process-asl/process-asl/pulls/13"},"html":{"href":"https://github.com/process-asl/process-asl/pull/13"},"issue":{"href":"https://api.github.com/repos/process-asl/process-asl/issues/13"},"comments":{"href":"https://api.github.com/repos/process-asl/process-asl/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/process-asl/process-asl/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/process-asl/process-asl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/process-asl/process-asl/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/process-asl/process-asl/statuses/50d50fa2b8e2265dd177cd6d244890104f8a199a"}}}}