I would like to use GNU parallel to run a command for multiple systems.
The command would be:
nimadm -c <system> -l lppsource73 -s spot73 -o bosinst_migration -j nimadm_vg -d hdisk0 -Y
for I have a list of systems in a variable.
I tried following in parallel:
parallel nimadm -c ::: $HOSTS -l lppsource73 -s spot73 -o bosinst_migration_73 -j nimadm_vg -d hdisk0 -Y
Unfortunately it is not working... parallel starts a job for everything after the ":::"
Can you help me please?
Thanks in advance...
best regards,
Joerg
parallel nimadm -c {} -l lppsource73 -s spot73 -o bosinst_migration -j nimadm_vg -d hdisk0 -Y ::: $HOSTS
This is covered in:
the cheatsheet https://www.gnu.org/software/parallel/parallel_cheat.pdf
the book https://www.lulu.com/shop/ole-tange/gnu-parallel-2018/paperback/product-23558902.html or download it at: https://doi.org/10.5281/zenodo.1146014 Read at least chapter 1+2. It should take you less than 20 minutes.
the intro videos: https://youtube.com/playlist?list=PL284C9FF2488BC6D1
If you want to dive deeper: spend a couple of hours walking through the tutorial (man parallel_tutorial). Your command line will love you for it.
You can also find a lot of examples of use in man parallel_examples.
thanks for reading.
I´m new in the world of neuroimaging, where I want to quantify certain structures in the brain (Locus coeruleus), using ANTS and a Probabilistic Atlas of the Human Locus Coeruleu (https://www.nitrc.org/projects/lc_7t_prob/)
The creators of the atlas provide a pipeline, which I attach below. My question is, if I have the database of subjects with their respective MRI images (T1, FLAIR, etc), how do I run the pipeline using ANTS, to quantify through the atlas?
I´m currently working on macOS M1
pipeline:
#!/bin/bash
module load ANTS/2.2.0
#1. Build averaged MT-on image while registering individual images in an unified step
antsMultivariateTemplateConstruction2.sh -d 3 -o t_ -i 4 -g 0.1 -j 1 -c 5 -k 1 -w 1 -f 8x4x2x1 -s 3x2x1x0 -q 100x70x50x20 -n 1 -r 1 -l 1 -m MI -t Rigid *LC_SN_112*.nii.gz
#2. Co-register MT-off image to the corresponding individual averaged MT-on image
N4BiasFieldCorrection -d 3 -i noMT.nii.gz -o n4_noMT.nii -r 1 -c [50x50x30x20,1e-6] -b [200];
gzip n4_noMT.nii
antsRegistration -v 1 -d 3 -o noMT_to_average -n Linear -u 0 -w [0.005,0.995] -r [t_template0.nii.gz,n4_noMT.nii.gz,1] -t Rigid[0.1] -m MI[t_template0.nii.gz,n4_noMT.nii.gz,1,32,Regular,0.25] -c [1000x500x250x100,1e-6,10] -f 12x8x4x2 -s 4x3x2x1vox -x [NULL,NULL] -u 0
antsApplyTransforms -d 3 -i n4_noMT.nii.gz -o noMT_to_template0.nii.gz -r t_template0.nii.gz -n Linear -t noMT_to_average0GenericAffine.mat
#3. Co-register MT-off image to the corresponding individual T1 MP2RAGE image
antsRegistration -v 1 -d 3 -o [noMT_to_T1,noMT_to_T1Warped.nii.gz,noMT_to_T1InverseWarped.nii.gz] -n Linear -u 0 -w [0.005,0.995] -t Rigid[0.1] -m MI[n4mag0000_PSIR_std.nii,n4_noMT.nii.gz,1,32,Regular,0.25] -c [1000x500x250x100,1e-6,10] -f 12x8x4x2 -s 4x3x2x1vox -x [NULL,NULL] -u 0
antsApplyTransforms -d 3 -i n4_noMT.nii.gz -o noMT_to_T1.nii.gz -r n4mag0000_PSIR_std.nii -n Linear -t noMT_to_T10GenericAffine.mat
#4. Build the study-wise T1 template
antsMultivariateTemplateConstruction2.sh -d 3 -c 5 -g 0.1 -i 6 -q 100x100x70x50x20 -f 10x6x4x2x1 -s 5x3x2x1x0vox -n 0 -o T1TMP_ -r 0 -l 1 -m CC -t SyN -k 1 -v 8gb T1_list_brain_CSFin_denoised_n53.txt
#5. Coregister T1 template to the ICBM2009b template
source=T1TMP_template0.nii
target=mni_icbm152_t1_tal_nlin_asym_09b_hires_FSL_bbox_struc_brain_CSFin.nii
antsRegistration \
--verbose 1 \
--dimensionality 3 \
--float 0 \
--output \
[T1TMP_53_To_MNI152,T1TMP_53_To_MNI152_Warped.nii.gz,T1TMP_53_To_MNI152_InverseWarped.nii.gz] \
--interpolation Linear \
--use-histogram-matching 0 \
--winsorize-image-intensities [0.005,0.995] \
--initial-moving-transform [${target},${source},1] \
--transform Rigid[0.1] \
--metric CC[${target},${source},1,4] \
--convergence [100x70x50x50,1e-6,10] \
--shrink-factors 8x4x2x1 \
--smoothing-sigmas 3x2x1x0vox \
--transform Affine[0.1] \
--metric MI[${target},${source},1,32,Regular,0.25] \
--convergence [1000x500x250x100,1e-6,10] \
--shrink-factors 12x8x4x2 \
--smoothing-sigmas 4x3x2x1vox \
--transform SyN[0.1,3,0] \/Users/VictorVidal/R08_t1_mprage_sag_p2_iso_20180520172539_5.nii
--metric CC[${target},${source},1,4] \
--convergence [100x100x70x50x20,1e-6,10] \
--shrink-factors 10x6x4x2x1 \
--smoothing-sigmas 5x3x2x1x0vox \
#6. Coregister averaged MT-on images to MNI space
antsApplyTransforms -d 3 -i ${MT_Path}/t_template0.nii.gz -o ${output_Path}/avgMT_to_MNI_TL_CC.nii.gz -r ${MNI_Path}/mni_icbm152_t1_tal_nlin_asym_09b_hires_FSL_bbox_struc_brain_CSFin.nii -n Linear -t ${MNI_Path}/T1TMP_54_CC_To_MNI152_T109b_FSL_bbox_brain_CSFin_RegAllCC1Warp.nii.gz -t ${MNI_Path}/T1TMP_54_CC_To_MNI152_T109b_FSL_bbox_brain_CSFin_RegAllCC0GenericAffine.mat -t ${T1_Path}/T1TMP_${subj}_*1Warp.nii.gz -t ${T1_Path}/T1TMP_${subj}_*.mat -t [${MT_Path}/T1_to_noMT0GenericAffine.mat,1] -t [${MT_Path}/noMT_to_average0GenericAffine.mat,1] -v 1```
I have been using tmux in iTerm2 for a while now but I have not been using the tmux integration that now comes with iTerm2.
I started looking at using the tmux intergration as it allows you to use the shell intergration inside tmux.
The problem i am encountering is that after i do tmux -CC none of the key bindings inside my .tmux.conf work... I cant even get any of the defaults to work. I would really like to use tmux integration but cant unless i can get the key bindings in my .tmux.conf to work.
Some of the bindings that are not working are;
Rebound the prefix key to C-s
bind-key \ split-window -v -c '#{pane_current_path}'
bind-key - split-window -h -c '#{pane_current_path}'
These are just a couple of examples but basically nothing seems to be working...
My .tmux.conf is
# improve colors
set-option -g default-terminal "screen-256color"
# set base Prefix key to ctrl-s
unbind C-b
set -g prefix C-s
bind-key -r C-s send-prefix
# reload the source config
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
set-option -g status-keys "emacs"
#change colour of status bar
set-option -g status-bg '#666666'
set-option -g status-fg '#aaaaaa'
# set window split
bind-key - split-window -v -c '#{pane_current_path}'
bind-key \ split-window -h -c '#{pane_current_path}'
# set text in status bar
set -g status-interval 1
set -g status-justify centre # center align window list
set -g status-left-length 50
set -g status-right-length 140
set -g status-left '#[fg=green]#H #[fg=black]• #[fg=green,bright]#(uname -r | cut -c 1-6)#[default]'
set -g status-right '#[fg=green,bg=default,bright]#(tmux-mem-cpu-load -i 1) #[fg=red,dim,bg=default]#(battery -at) #[fg=white,bg=default]%a%l:%M:%S %p#[default] #[fg=blue]%Y-%m-%d'
# Fine adjustment (1 or 2 cursor cells per bump)
bind -n S-Left resize-pane -L 2
bind -n S-Right resize-pane -R 2
bind -n S-Down resize-pane -D 1
bind -n S-Up resize-pane -U 1
# new window opens in same directory
bind c new-window -c "#{pane_current_path}"
# set window numbering to start from 1
set -g base-index 1
set -g renumber-windows on
# allow to take a pane and put it into new window
bind-key b break-pane -d
# allows ctrl-j to open tree of tmux sessions
bind-key C-j choose-tree
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# Update default binding of `Enter` to also use copy-pipe
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
# History
set -g history-limit 10000
# Mouse mode
set-option -g mouse on
# Rename Tab
set-option -g set-titles on
# Terminal notifier doesnt work with tmux
set -g default-command "which reattach-to-user-namespace > /dev/null && reattach-to-user-namespace -l $SHELL || $SHELL -l"
set-option -sg escape-time 10
Copying my answer at https://stackoverflow.com/a/47171067/4200039 over:
Someone reported a similar bug at iTerm2 Tmux Integration Default Keybindings not working in 2015. The response from the developer George Nachman suggests that keybindings are not supported:
One of the main goals of the tmux integration is that you use iTerm2's
keystrokes, not tmux's. If there's a specific workflow that you can't
accomplish natively, let me know--there is a lot of power in the
ability to remap keys in iTerm2.
This should be flagged as a duplicate of iTerm 2 not honoring key bindings declared in .tmux.conf but I can't flag it until it has an accepted or upvoted answer.
I am trying to write a script I can run/source so tmux set a specific layout and run commands. I have some results.
Here is what I've written so far:
selectp -t 1
splitw -v -p 15
splitw -h -p 50
selectp -t 1
send-keys 'cd ~/code/octoly' Enter
send-keys 'vim .' Enter
selectp -t 2
send-keys 'cd ~/code/octoly' Enter
send-keys 'drails c' Enter
new-window -d -n server -c ~/code/octoly
selectw -t 2
send-keys 'fd' Enter
splitw -h -p 50
send-keys 'cd ~/code/octoly' Enter
send-keys 'drails s' Enter
selectp -t 1
splitw -v -p 50
send-keys 'cd ~/code/octoly' Enter
send-keys 'be guard' Enter
What works more or less is the creation of the second window and the panes. Though the panes does not give me what I want. They are all created in the first window, none are created in the second.
Here is what I run to start tmux:
tmux new 'tmux move-window -t 99 \; source-file ~/.tmux/session_octoly'
Furthermore, where I'm really lost is that if I run each command by hand one by one, it gives me what I want.
What am I missing here?
First of all, you're using the -d flag in new-window that does not make the new window the current window:
If -d is given, the session does not make the new window the current window.
However I would probably spin up tmux in a different way, using tmux -f flag to use an ad-hoc config file that does what you want.
Please check the commands before running it in you're environment.
# File: ~/.tmux/octoly.conf
# Load default .tmux.conf
source-file ~/.tmux.conf
# setup octoly session
new-session -s octoly -n editor -d -c ~/code/octoly
send-keys 'vim .' Enter
split-window -v -p 15 -c ~/code/octoly
send-keys 'drails c' Enter
split-window -h -p 50 -c ~/code/octoly
# Select vim pane
select-pane -t 1
# create second window
new-window -n server -c ~/code/octoly
send-keys 'fd' Enter
split-window -h -p 50 -c ~/code/octoly
send-keys 'drails s' Enter
select-pane -t 1
split-window -v -p 50 -c ~/code/octoly
send-keys 'be guard' Enter
# Optional step, reselect window 1 (the one with vim)
select-window -t editor
Then you need to launch tmux using:
tmux -f ~/.tmux/octoly.conf attach
Another alternative would be to build a bash script sending the same commands.
Note: I've used the -c flag to specify the start directory instead of running every time a cd command. Given that every command is run in the same folder you can take them out in the split-window commands.
When I am trying to use the below code in RStudio I am getting error.
Code:
system(paste("sshpass -v -f -N -o StrictHostKeyChecking=no -i '<Path>/id_rsa.ppk' -L 3306:localhost:3306 root#127.0.0.1 sleep 20"))
Warning:
running command 'sshpass -v -f -N -o StrictHostKeyChecking=no -i '<Path>/id_rsa.ppk' -L 3306:localhost:3306 root#127.0.0.1 sleep 20' had status 127
How can I resolve the above issue in R?