Sign in to follow this  
Followers 0
drlacus

Batch equivalent in OS X

4 posts in this topic

Hi guys and girls!

 

I have a huge problem, but overcoming it could simplify my whole work. 

 

I have to perform some task and I know it could be done much more easier, but as I was educated in a Windows based environment and I do not know OS X as well as Windows or DOS. 

So, here it goes.

 

I have to create a batch file equivalent in OS X that performs the following tasks. The commands are executed in a terminal window. These perform mathematical operations with cortical brain masks and overwrite the source files as they are not needed anymore:

 

fslmaths R_S1.nii.gz -sub R_M1.niigz -bin R_S1.nii.gz 

fslmaths R_M1.nii.gz -add R_S1.nii.gz mix

fslmaths R_Premotor.nii.gz -sub mix.nii.gz -bin R_Premotor.nii.gz

fslmaths R_Premotor.nii.gz -add mix.nii.gz mix

fslmaths R_frontal_lobe.nii.gz -sub mix.nii.gz -bin R_frontal_lobe.nii.gz

fslmaths R_frontal_lobe.nii.gz -add mix.nii.gz mix

fslmaths R_temporal_lobe.nii.gz -sub mix.nii.gz -bin R_temporal_lobe.nii.gz

fslmaths R_temporal_lobe.nii.gz -add mix.nii.gz mix

fslmaths R_occipital_lobe.nii.gz -sub mix.nii.gz -bin R_occipital_lobe.nii.gz

fslmaths R_occipital_lobe.nii.gz -add mix.nii.gz mix

fslmaths R_parietal_lobe.nii.gz -sub mix.nii.gz -bin R_parietal_lobe.nii.gz

 

How to create this file and after inserting the "batch" file in a given folder can it be executed folder specifically?

 

Thank you for your help and please forgive my noobness :D

Share this post


Link to post
Share on other sites

You need to give the file the 'execute' permission.

 

This page gives a basic overview of how permissions work in OSX and how to set them.

 

http://www.macinstruct.com/node/415

Share this post


Link to post
Share on other sites

You need a shell script. Just put those commands in a text file and put

#!/bin/sh
on the first line of it. After setting execute permissions as vitorio mentioned you should be able to run it as if it was a command either from a terminal or the GUI.
1 person likes this

Share this post


Link to post
Share on other sites

Thank you for your help guys!

 

It worked :)

1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.